Answer the question
In order to leave comments, you need to log in
How to move some modules into a separate chunk in Webpack4?
I want to move all modules from node_modules to chunk 'vendor' except for angular - move it to chunk 'angular'. Configuration example below:
splitChunks: {
minSize: 0,
chunks: 'all',
cacheGroups: {
vendor: {
name: 'vendor',
test: /\/node_modules\//
},
angular: {
name: 'angular',
test: /\/node_modules\/(rxjs|@angular)\//
}
}
}
splitChunks: {
minSize: 0,
chunks: 'all',
cacheGroups: {
vendor: {
name: 'vendor',
test: (chunks) => {
if (!/\/node_modules\//.test(chunks.resource)) return false;
return !/\/node_modules\/(rxjs|@angular)\//.test(chunks.resource);
}
},
angular: {
name: 'angular',
test: (chunks) => {
if (!/\/node_modules\//.test(chunks.resource)) return false;
return /\/node_modules\/(rxjs|@angular)\//.test(chunks.resource);
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Better look in the direction of DLLPlugin
https://webpack.js.org/plugins/dll-plugin/#examples
Just breaking into chunks will not solve the build speed problem, everything will still be rebuilt on every run.
With DLLPlugin, vendors can only be rebuilt when they are updated.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question