轉載: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']