d2-admin build 决绝打包报错的问题

之前npm run build打包项目都是正常的,今天打包一直报ERROR in xxx from UglifyJs RangeError: Maximum call stack size exceeded错误,

最终解决方案:

webpack.prod.conf.js 配置中 使用 terser-webpack-plugin 替代 uglifyjs-webpack-plugin

还有一个UglifyJs打包时报错“UglifyJs Unexpected token: name «Dom7», expected: punc «;»”,也可以通过换插件的方式解决

新的配置:

optimization: {
    minimize: true,
    minimizer: [new TerserPlugin({
      parallel: 4, // 并行打包
      terserOptions: {
        ecma: undefined,
        warnings: false,
        parse: {},
        compress: {
          drop_debugger: false,  // 除了这两句是我加的,基他都是默认配置
          drop_console: true
        },
        mangle: true, // Note `mangle.properties` is `false` by default.
        module: false,
        output: null,
        toplevel: false,
        nameCache: null,
        ie8: false,
        keep_classnames: undefined,
        keep_fnames: false,
        safari10: false,
      }
    })],
    ......
}

你可能感兴趣的:(d2-admin build 决绝打包报错的问题)