I was using CommonsChunkplugin to split my codes.Now I'm trying to migrate my project to webpack 4.
Here is the old config code:
entry: {
main: './src/app.js',
vendor: ['babel-polyfill','react','react-dom',"jquery","bootstrap"]
},
new webpack.HashedModuleIdsPlugin({
// Options...
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor'
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest'
})
And here is the webpack 4 config code:
entry: {
main: './src/app.js'
},
optimization: {
splitChunks: {
cacheGroups: {
default: false,
commons: {
test: /[\\/]node_modules[\\/]/,
name: "vendor",
chunks: "initial"
}
}
}
},
The new config code takes all the code from node modules which is used in the project. But I want only the vendor libraries(which I define at the enrtry config part)to be split.Not all code from node_modules.
In this case: 'babel-polyfill','react','react-dom',"jquery","bootstrap"
entry: {
main: './src/app.js',
vendor: ['babel-polyfill','react','react-dom',"jquery","bootstrap"]
},
And my other questions:
2) Do I need HashedModuleIdsPlugin anymore?
3) Do I need to split runtime code?