原文链接: vue cli3 去除 console
https://www.npmjs.com/package/babel-plugin-transform-remove-console
npm install babel-plugin-transform-remove-console --save-dev
.babelrc
// with options
{
"plugins": [ ["transform-remove-console", { "exclude": [ "error", "warn"] }] ]
}
// without options
{
"plugins": ["transform-remove-console"]
}
安装 transform-remove-console
修改 babel.config.js
const plugins = []
if (process.env.NODE_ENV === 'production') {
plugins.push('transform-remove-console')
}
module.exports = {
presets: [
'@vue/app'
],
plugins
}