1. Install the Terser-webpack-plugin
npm install terser-webpack-plugin --save-dev
Copy the code
  1. usingchainWebpackChain calls
// vue.config.js
module.exports = {
   chainWebpack(config){ config .when(process.env.NODE_ENV ! = ='development'.config= > {
        config.optimization
          .minimizer('terser')
          .tap(options= > {
            options[0].terserOptions.compress.drop_console = true
            return options
          })
      })
  },
}
Copy the code