vue-cli3, vue 打包生产环境 npm run build 去掉console

vue-cli3, vue 打包生产环境 npm run build 去掉console

使用:babel-plugin-transform-remove-console 插件。

1.安装依赖

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

2.找到babel.config.js文件,

代码如下:

const plugins = ["@vue/babel-plugin-transform-vue-jsx"]
// 生产环境移除console
if(process.env.NODE_ENV === 'production') {
  plugins.push("transform-remove-console")
}
module.exports = {
  plugins: plugins,
  presets: [
    '@vue/app'
  ]
}
posted @ 2021-07-13 21:45  柯宝宝智商感人  阅读(331)  评论(1编辑  收藏  举报