官方文档上是用插件: new webpack.optimize.CommonsChunkPlugin({ name: ‘common‘ // 指定公共 bundle 的名称。 }) 但报错:webpack.optimize.CommonsChunkPlugin has been removed, please use config.optimization.splitChunks
官方文档上是用插件:
new webpack.optimize.CommonsChunkPlugin({ name: ‘common‘ // 指定公共 bundle 的名称。 })
但报错:webpack.optimize.CommonsChunkPlugin has been removed, please use config.optimization.splitChunks instead
webpack4无此插件配置,应该使用配置化生成:
在entry的同级增加以下配置:
optimization: {
splitChunks: {
cacheGroups: {
commons: {
name: "commons",
chunks: "initial",
minSize: 1
}
}
}
}