配置 new webpack.optimize.CommonsChunkPlugin({ name: 'vendor' })這個之后,執(zhí)行npm run build,出現(xiàn)報錯.
Error: webpack.optimize.CommonsChunkPlugin has been removed, please use config.optimization.splitChunks instead.
Error: webpack.optimize.CommonsChunkPlugin has been removed, please use config.optimization.splitChunks instead.
2018-03-01
舉報
2018-03-09
感謝樓主
2018-03-05
這是我的代碼:
config.plugins.push(
? ? new ExtractPlugin('styles.[contentHash:8].css')
? )
? config.optimization = {
? ? splitChunks: {
? ? ? cacheGroups: {
? ? ? ? commons: {
? ? ? ? ? chunks: 'initial',
? ? ? ? ? minChunks: 2, maxInitialRequests: 5,
? ? ? ? ? minSize: 0
? ? ? ? },
? ? ? ? vendor: {
? ? ? ? ? test: /node_modules/,
? ? ? ? ? chunks: 'initial',
? ? ? ? ? name: 'vendor',
? ? ? ? ? priority: 10,
? ? ? ? ? enforce: true
? ? ? ? }
? ? ? }
? ? },
? ? runtimeChunk: true
? }
2018-03-01
具體可以查看webpack 4.0版本的修改http://ju.outofmemory.cn/entry/343762
2018-03-01
問題已經(jīng)解決,將解決方法分享給遇到同樣問題的朋友.
這個是webpack 4.0版本寫法發(fā)生改動導致的問題.
在config里添加下邊的代碼,即可解決
2018-03-01
根據(jù)提示,使用config.optimization.splitChunks 這個配置依然報錯:
TypeError: Cannot read property 'splitChunks' of undefined