create-react-app 打包时去除 console
在 webpack.config.js 中找到下图代码的位置,添加配置
pure_funcs: ['console.log']
ps: 需要执行 npm run eject
才能暴露出webpack配置文件
如上配置会在打包时将代码中的 console.log
调用都去掉,其他console调用不会去掉
参考资料:terser/terser: 🗜 JavaScript parser, mangler and compressor toolkit for ES6+ (github.com)