vue-cli4使用terser-webpack-plugin时exclude不生效?
关于vue-cli4使用terser-webpack-plugin时, exclude不生效
我的目的就是想让utils.js文件下 console.* 都能打印 其余文件的console移除
- vue-cli4本自带terser,使用过exclude,发现打印出来没有exclude于是安装了插件
 
// 原始代码config.when(process.env.NODE_ENV === 'production', (config) => {
      config.optimization.minimizer('terser').tap((args) => {
        args[0].terserOptions.compress.drop_console = true
        args[0].terserOptions.compress.drop_debugger = true
        args[0].terserOptions.compress.pure_funcs = ['console.log']
        args[0].terserOptions.output = {
          comments: false,
        }
        return args
      })
- 接着自行升级了cli和安装terser-webpack-plugin
 
"@vue/cli-service": "~4.5.19",
"terser-webpack-plugin": "~4.2.3",
config.optimization.minimizer('terser').use(TerserPlugin, [        {
          minify: TerserPlugin.esbuildMinify,
          terserOptions: {
            compress: {
              drop_console: true,
              drop_debugger: true,
            },
            mangle: {
              safari10: true, // 解决ie,safari10.1不支持ES6语句
            },
          },
          exclude: /\/utils/,
        },
      ])
已经添加了exclude,utils.js 文件不做处理,但是正式环境还是没有打印
确认过插件是生效的,因为drop_console开启了,控制台没有任何打印
不知道哪个环境出了问题
以上是 vue-cli4使用terser-webpack-plugin时exclude不生效? 的全部内容, 来源链接: utcz.com/p/935363.html

