The official document uses a plug-in:
new webpack.optimize.CommonsChunkPlugin({ name:'common' // Specify the name of the common bundle. })
but an error: webpack .optimize.CommonsChunkPlugin has been removed, please use config.optimization.splitChunks instead
webpack4 does not have this plugin configuration, it should be generated by configuration:
Add the following configuration at the same level of entry:
optimization: {
splitChunks: {
CacheGroups: {
Commons: {
Name: “commons”,
Chunks: “initial”,
MinSize: 1
div> div>
}
}
optimization: {
splitChunks: {
CacheGroups: {
Commons: {