webpackChain配置不生效



  •  webpackChain(chain, webpack) {
          chain
            .plugin("ignore")
            .use(new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/));
          chain.plugin("loadshReplace").use(new LodashModuleReplacementPlugin());
          chain.plugin("optimizeCss").use(new OptimizeCssAssetsPlugin());
    
          // chain
          //   .plugin("analyzer")
          //   .use(require("webpack-bundle-analyzer").BundleAnalyzerPlugin, []);
          chain.merge({
            optimization: {
              minimize: true,
              splitChunks: {
                chunks: "all",
                name: true,
                minChunks: 2,
                maxSize: 500000,
                minSize: 102400,
                cacheGroups: {
                  lodash: {
                    name: "lodash",
                    priority: 1000,
                    test(module) {
                      return /node_modules[\\/]lodash/.test(module.context);
                    }
                  }
                }
              }
            }
          });
        },
        commonChunks(commonChunks) {
          commonChunks.push("lodash");
          return commonChunks;
        }
    


  • 请问你这个问题解决了吗,我也越到了这个问题,配置了splitChunks没有生效


登录后回复