Open larsholleboom-luminis opened 2 years ago
Yes this has to do with webpack 5.
Please fix the 'apply' function in index.js This replacement code will make it work ` apply(compiler) {
const { webpack } = compiler;
compiler.hooks.thisCompilation.tap('AngularTemplateCacheWebpackPlugin', (compilation) => {
compilation.hooks.additionalAssets.tapAsync('AngularTemplateCacheWebpackPlugin', (callback) => {
let cachedTemplates = '';
this.templatelist.forEach((template) => {
cachedTemplates += template + '\n';
});
// Insert this list into the webpack build as a new file asset:
// compilation.assets[this.options.outputFilename] = {
// source: function () {
// return cachedTemplates;
// },
// size: function () {
// return cachedTemplates.length;
// },
// };
compilation.assets[this.options.outputFilename] = new webpack.sources.RawSource(cachedTemplates.toString())
callback();
});
});
}`
I have set up an Angular 12 app with AngularCustomWebpackConfig configuring as follows:
const AngularTemplateCacheWebpackPlugin = require('angular-templatecache-webpack-plugin'); module.exports = { plugins: [ new AngularTemplateCacheWebpackPlugin({ source: './src/app/angular-js/*/.html', standalone: true }) ] };
running will give me the following error: An unhandled exception occurred: scriptAssetSource.sourceAndMap is not a function.
Other plugins I've tried, do work. The only thing I could find is that it has to do with webpack version 5