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

According to the guidelines webpack, knocking the demo CommonsChunkPlugin used in this plugin, reported the following error:

 

 Use the guide:

    plugins: [
       new new HTMLWebpackPlugin ({ 
        title: 'Code Splitting' 
       }),
 +      new new webpack.optimize.CommonsChunkPlugin ({
 + name: 'Common' // specified public bundle name. 
+      }) 
    ],

Solution:

    plugins: [
       new new HTMLWebpackPlugin ({ 
        title: 'Code Splitting' 
       }),
 -      new new webpack.optimize.CommonsChunkPlugin ({
 - name: 'Common' // specified public bundle name. 
-      }) 
    ],
 +   Optimization: {
 +     splitChunks : {
 +         cacheGroups: {
 +         commoms: {
 + name: 'Commons' ,
 + of chunks are: 'Initial' ,
 + minChunks: 2 
+         }
 +         }
 +     }
 +}

 

Guess you like

Origin www.cnblogs.com/hongyan90/p/12487473.html