Vite +Vue3打包生产环境去除项目中的console.log
背景
开发的过程中,为了方便测试程序,写了很多的console.log,打包发布项目的时候,发现这些console.log也同步输出了,生产环境下这肯定是不合适的,但是一个一个的删除console.log又挺麻烦怎么办呢?
解决方案
在“vite.config”文件中,新增如下配置项:
esbuild: {
drop: ['console', 'debugger'],
},
设置完成后,为了安全,npm run preview 预览一下确定是否生效,然后再打包上传!
啥是esbuild?
