webpack4.x CommonsChunkPlugin 问题

plugins:[
    new webpack.optimize.CommonsChunkPlugins({
        name:'commons',
        filename:'commons.js',
        minChunks:2
    })
]

显示错误信息

Error: webpack.optimize.CommonsChunkPlugin has been removed, please use config.optimization.splitChunks instead.

可以查看官方文档

给出的信息是4.X已经删除了CommonsChunkPlugin,更改为SplitChunksPlugin,上面的配置文件更改为

 

optimization: {
        splitChunks: {
            minSize:0, 
            cacheGroups: {
                commons: {
                    name:'commons',
                    chunks:'initial',
                    minChunks:2,
                    
                }
            }
        }
    }

 

你可能感兴趣的:(前端)