- 类型:
boolean | ConsoleType[]
- 默认值:
false
在生产模式构建时,是否自动移除代码中的 console.[methodName]。
全部移除
当 removeConsole 被设置为 true 时,会移除所有类型的 console.[methodName]:
rsbuild.config.ts
export default {
performance: {
removeConsole: true,
},
};
指定类型
你也可以指定仅移除特定类型的 console.[methodName],比如移除 console.log 和 console.warn:
rsbuild.config.ts
export default {
performance: {
removeConsole: ['log', 'warn'],
},
};
目前支持配置以下类型的 console:
type ConsoleType = 'log' | 'info' | 'warn' | 'error' | 'table' | 'group';