Talent determines the upper limit, effort determines the lower limit

One tip a day, one optimization point a day. Accumulate slowly and summarize slowly.

The console is removed from the production environment

  • Babel-plugin-transform-remove-console Official address
Yarn add babel-plugin-transform-remove-console -d // Installation packageCopy the code

Configure in babel.config.js

// All production environments const prodPlugin = []if (process.env.NODE_ENV === 'production') {// In a production environment, the printed logs are automatically cleared, but the error and WARN prodplugin.push (['transform-remove-console', {// Exclude console.error and console.warn: ['error'.'warn']
    }
  ])
}


module.exports = {
  presets: [
    '@vue/cli-plugin-babel/preset'
  ],
  plugins: [
    ...prodPlugin
  ]
}
Copy the code

Following the above configuration, the packaged project will retain only the Console for Error and WARN.


❤️ do me a favor

If you find this article inspiring, I’d like to ask you to do me a small favor:

  1. Like, so that more people can see this content (collection does not like, is a rogue -_-)

  2. Pay attention to the public account “Tomatology front-end”, I will regularly update and release front-end related information and project case experience for your reference.

  3. Adding a friend may not help you a lot, but there are some business issues that can be discussed and exchanged.