1. TerserPlugin plug-in


  • 1. Install
yarn add terser-webpack-plugin
Copy the code
  • 2. Add the code to vue.config.js
module.exports = {
    configureWebpack:{
        optimization:{
            minimizer: [new TerserPlugin({ terserOptions: { compress: { drop_console: true } } })]
        }
    }
}
Copy the code

2. Vue CLI configuration (available in version 4.0)

  • Add the code in vue.config.js
Console configureWebpack(config) {if (process.env.node_env === 'production') { config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true } }Copy the code