
优化打包:排除特定 console 方法
问题:
在 vite 5 打包时,想要清除特定的 console 方法,如 console.log,但不清除其他方法,如 console.info。如何配置?
解答:
解决此问题的步骤如下:
// vite.config.js
export default {
build: {
terserOptions: {
ecma: 2020,
keep_fargs: false,
compress: {
drop_console: true,
keep_fargs: true,
pure_getters: true,
},
keep_classnames: true,
keep_fnames: true
}
}
};这样配置后,vite 5 在打包时将清除 console.log 但保留 console.info。
以上就是Vite 5 打包:如何只清除 console.log 方法,保留 console.info 方法?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号