【项目记录】vue项目打包去除console、注释等

vue-cli2项目:

build/webpack.prod.conf.js

new UglifyJsPlugin({
          uglifyOptions: {
            compress: {
              drop_console: true,//console
              drop_debugger: true,
            }
          }
      })

vue-cli3项目:

vue.config.js

module.exports = defineConfig({
  chainWebpack(config) {
    args[0].terserOptions.compress.drop_console = true;
    args[0].terserOptions.compress.drop_debugger = true;
    return args
  }
})

你可能感兴趣的:(Vue,vue.js,javascript,前端)