一、vue生产环境去掉debugger和console

npm install terser-webpack-plugin -D

二、在vue.config.js文件里添加插件的配置

在这里插入图片描述

configureWebpack: config => {
    if (process.env.NODE_ENV === 'production') {
      config.optimization.minimizer[0].options.terserOptions.compress.warnings = false
      config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
      config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true
      config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = ['console.log']
    }
  },
Logo

前往低代码交流专区

更多推荐