source.define
- Type:
Record<string, unknown> - Default:
{}
Replaces variables in your code with other values or expressions at compile time. This enables different behavior between development and production builds.
Each configuration key represents an identifier or multiple identifiers joined with .:
- String values are used as code fragments.
- Other types (including functions) are stringified.
- Object values define all keys the same way.
- Keys prefixed with
typeofare only defined for typeof calls.
For more usage, see Using define and Rspack - DefinePlugin.
Example
rsbuild.config.ts
Expressions are replaced with the corresponding code fragments:

