1. プラグイン babel-plugin-transform-remove-console をインストールします
cnpm install babel-plugin-transform-remove-console
2. babel.config.js ファイルを見つけて変更します。
// 项目发布阶段用到的babel插件
const prodPlugins = []
if (process.env.VUE_APP_SERVER_ENV === 'prod') {//当生产环境时,使用remove-console插件,屏蔽所有的打印语句
prodPlugins.push('transform-remove-console')
}
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
],
plugins: [
// 发布产品时的插件数组
...prodPlugins
]
}