vue-cli3.0 生产包去除console.log

转载:https://www.cnblogs.com/KlllB/p/10682262.htmlhtml

不安装插件去除console.log的方法vue

vue-cli3.0在打包过程当中就使用了terser-webpack-plugin插件进行优化,具体配置能够node_modules/@vue/cli-service/lib/config/prod.js中看到。node

这里使用了环境变量进行控制,只有打生产包的时候才会调用这个插件进行打包优化。webpack

terser-webpack-plugin的具体配置在同一个文件夹下terserOptions.js中,只要在这个文件中compress对象中加入如下几个属性就能够了web

warnings: false,
drop_console: true,
drop_debugger: true,
pure_funcs: ['console.log']
相关文章
相关标签/搜索