您当前的位置: 首页 > 

任磊abc

暂无认证

  • 6浏览

    0关注

    182博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

vue-cli3.0或者nuxt.js打包生产环境下删除console.log

任磊abc 发布时间:2020-11-11 18:28:05 ,浏览量:6

首先下载babel-plugin-transform-remove-console插件

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

2 在nuxt.config.js添加判断生产环境还是开发环境

let plugins= []

if(process.env.NODE_ENV === 'production'){
  plugins.push("transform-remove-console")
}

在nuxt.config.js的build里

module.exports = {
            ...
            build: {
              babel: {
                plugins
              },
            }
            ...
}

同样在vue-cli3.0环境下也是的【babel.config.js】中配置如下:

module.exports = {
 
  plugins: plugins
}

关注
打赏
1656830895
查看更多评论
立即登录/注册

微信扫码登录

0.0490s