It is not safe to have console.log in the production environment, so we need to remove it. The tool we use is terser-webpack-plugin. The scaffolding version I used does not need to be installed.

  • Add the following code to vue.config.js
module.exports = {
  // Remove the console during production
  configureWebpack: (config) = > {
    if (process.env.NODE_ENV === 'production') { // Check whether it is a production environment. The development environment is not removed
      config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true}}},Copy the code
Go to this ok, go to try quickly!!