We are using Aurelia 1 and Webpack 5. We upgraded from Webpack 4. We noticed that our index.html file now includes a script tag for every single javascript file produced by the splitChunks plugin. This is about 150 javascript files. At some point in the past only a single js file was included and everything was lazy loaded when it was needed. However, now it’s just adding everything. I’m not sure when this happened, however, I believe it was when we upgraded to Webpack 5.
Our relevant webpack.config.js settings are:
entry: {
app: ['aurelia-bootstrapper']
},
optimization: {
runtimeChunk: true, // separates the runtime chunk, required for long term cacheability
minimize: production,
minimizer: [
new TerserPlugin({
//cache: true,
parallel: true,
terserOptions: {
//ecma: platform === 'es6' ? 2015 : 5
ecma: 2018
}
}),
new CssMinimizerPlugin()
],
splitChunks: {
chunks: 'all',
minSize: 20000,
maxSize: 500000,
minRemainingSize: 0,
minChunks: 1,
maxAsyncRequests: 30,
maxInitialRequests: 30,
}
},
new HtmlWebpackPlugin({
template: 'index.ejs',
minify: production ? {
removeComments: true,
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: false,
minifyCSS: true,
minifyJS: true,
removeScriptTypeAttributes: false,
removeStyleLinkTypeAttributes: true,
ignoreCustomFragments: [/\${.*?}/g]
} : undefined,
chunksSortMode: 'none',
}),