安装依赖:

    1. npm install babel-plugin-transform-remove-console --save-dev

    babel.config.js

    1. const prodPlugins=[]
    2. if(process.env.NODE_ENV === 'production'){
    3. prodPlugins.push("transform-remove-console")
    4. }
    5. module.exports = {
    6. presets: [
    7. '@vue/app'
    8. ],
    9. plugins: [...prodPlugins]
    10. }