I have a project that looks like this:
module1 is imported dynamically in app.js via import(/* webpackChunkName: 'module1' */ '@path')
.
I'm trying to configure the splitChunks plugin so it would output:
What is the best way to do that? The application has a single entry, which is app.js
Solved it with the following config. The key here is chunks: inital
in vendor cachegroup.
optimization: {
splitChunks: {
chunks: 'all',
maxInitialRequests: Infinity,
minSize: 0,
cacheGroups: {
vendors: false,
default: false,
vendor: {
chunks: 'initial',
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
reuseExistingChunk: true
},
},
},