码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2020-03-20 00:43:44      阅读:78      评论:0      收藏:0      [点我收藏+]

标签:webp   div   demo   指定   html   webpack   remove   bee   rem   

按照webpack的指南,敲的demo中用到CommonsChunkPlugin这个插件,报如下错误:

技术图片

 

 指南上的用法:

    plugins: [
      new HTMLWebpackPlugin({
        title: ‘Code Splitting‘
       }),
+     new webpack.optimize.CommonsChunkPlugin({
+       name: ‘common‘ // 指定公共 bundle 的名称。
+     })
    ],

解决方法:

    plugins: [
      new HTMLWebpackPlugin({
        title: ‘Code Splitting‘
       }),
-     new webpack.optimize.CommonsChunkPlugin({
-       name: ‘common‘ // 指定公共 bundle 的名称。
-     })
    ],
+  optimization: {
+    splitChunks: {
+        cacheGroups: {
+        commoms: {
+            name: ‘commons‘,
+            chunks: ‘initial‘,
+            minChunks: 2
+        }
+        }
+    }
+   }

 

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

标签:webp   div   demo   指定   html   webpack   remove   bee   rem   

原文地址:https://www.cnblogs.com/hongyan90/p/12487473.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!