首先,在项目根目录下找到 babel.config.js 或 .babelrc 文件。
打开该文件并添加以下配置:
{
"env": {
"development": {
"plugins": ["transform-remove-console"]
}
}
}
此配置仅在开发模式下移除“console”语句。如果需要在生产模式下移除,请使用以下配置:
{
"plugins": ["transform-remove-console"]
}