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

时间:2021-07-13 22:56:37   收藏:0   阅读:19

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‘
  ]
}

原文:https://www.cnblogs.com/kbbnice/p/15008602.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!