I am trying to split my chunks into main
and components
chunks. I want main to contain everything except components
and then components chunk to hold everything from src/js/components
. Right now this is including everything I want into main.bundle.hash.js
and is properly excluding the src/js/components
dir + all sub dirs BUT I don’t see a components.chunk.[contenthadsh].js
chunk being created. It is excluded completely when running webpack analyze.
How do I fix this?
optimization: {
splitChunks: {
cacheGroups: {
main: {
test: /[\/]src[\/]js[\/](?!components[\/]).+/,
name: 'main',
chunks: 'all',
enforce: true,
priority: 10
},
components: {
test: /[\/]src[\/]js[\/]components[\/].+/,
name: 'components',
chunks: 'all',
enforce: true,
priority: 5
}
}
},
minimize: true,
minimizer: [new TerserPlugin()]
},
output: {
path: outputPath,
filename: 'main.bundle.[contenthash].js',
publicPath,
chunkFilename: '[name].chunk.[contenthash].js',
}