For AI agents: the complete documentation index is available at https://rsbuild.rs/llms.txt, the full documentation bundle is available at https://rsbuild.rs/llms-full.txt, and this page is available as Markdown at https://rsbuild.rs/config/performance/remove-console.md.
close

performance.removeConsole

  • Type: boolean | ConsoleType[]
  • Default: false

Whether to remove console.[methodName] calls during JavaScript minification. This requires JavaScript minification to be enabled.

Side effects in the arguments are preserved. For example, removing console.log(doWork()) still evaluates doWork().

Remove all

When removeConsole is set to true, all types of console.[methodName] are removed:

rsbuild.config.ts
export default {
  performance: {
    removeConsole: true,
  },
};

Specific type

You can also specify to remove only certain types of console.[methodName], such as console.log and console.warn:

rsbuild.config.ts
export default {
  performance: {
    removeConsole: ['log', 'warn'],
  },
};

The following types of console are currently supported:

type ConsoleType = 'log' | 'info' | 'warn' | 'error' | 'table' | 'group';