webpack 压缩js文件配置 Error: webpack.optimize.UglifyJsPlugin has been removed, please use config.optimiza

文章目录

      • 场景
      • 解决

场景

  • 使用webpack压缩js文件的时候, 遇到了问题
Error: webpack.optimize.UglifyJsPlugin has been removed, please use config.optimization.minimize instead.

解决

  • 官方minimize
const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
    devtool: "source-map",
    optimization: {
        minimizer: [
            new TerserPlugin({
                cache: true, // 开启缓存
                parallel: true, // 支持多进程
                sourceMap: true, 
            }),
        ]
    }
};

你可能感兴趣的:(web)