The content of this section is derived from the content of the following links and is subject to the CC BY 4.0 license.
The following contents can be assumed to be the result of modifications and deletions based on the original contents if not specifically stated.
'production' | 'development' | 'none'
'production'
The mode
configuration is used to set the build mode of Rspack to enable the default optimization strategy.
You can set the mode directly in rspack.config.js
:
In actual scenarios, you can dynamically set the mode according to process.env.NODE_ENV
:
Alternatively, you can set the mode using the --mode
option on the Rspack CLI:
--mode
option on the CLI has a higher priority than mode
in rspack.config.js
.
mode
has the following optional values:
In production mode, Rspack automatically enables the following optimization strategies:
process.env.NODE_ENV
in code with 'production'
.optimization.minimize
to true
to enable SWC minification.In development mode, Rspack automatically enables the following optimization strategies:
process.env.NODE_ENV
in code with 'development'
.When mode
is set to 'none'
, Rspack will not enable any default optimization strategies.