'production' | 'development' | 'none'
>= 1.0.0
Specify the build mode for Rsbuild, as each mode has different default behavior and optimizations. For example, the production
mode will compress code by default.
The value of Rsbuild mode
is also be passed to the mode configuration of Rspack.
The value of mode
does not affect the loading results of the .env
file, as the .env
file is resolved before the Rsbuild configuration file.
Rsbuild CLI supports using the --env-mode
option to specify the env mode. See "Env mode" for more details.
The default value of mode
depends on the process.env.NODE_ENV
environment variable:
NODE_ENV
is production
, the default value is production
.NODE_ENV
is development
, the default value is development
.NODE_ENV
has any other value, the default value is none
.If you set the value of mode
, the value of NODE_ENV
will be ignored.
When using Rsbuild's command line:
rsbuild dev
will set the default values of NODE_ENV
and mode
to development
.rsbuild build
and rsbuild preview
will set the default values of NODE_ENV
and mode
to production
.When using Rsbuild's JavaScript API:
NODE_ENV
and mode
to development
.NODE_ENV
and mode
to production
.If the value of mode
is development
:
process.env.NODE_ENV
in the source code will be replaced with 'development'
.import.meta.env.MODE
in the source code will be replaced with 'development'
.import.meta.env.DEV
in the source code will be replaced with true
.import.meta.env.PROD
in the source code will be replaced with false
.If the value of mode
is production
:
process.env.NODE_ENV
in the source code will be replaced with 'production'
.import.meta.env.MODE
in the source code will be replaced with 'production'
.import.meta.env.DEV
in the source code will be replaced with false
.import.meta.env.PROD
in the source code will be replaced with true
.If the value of mode
is none
:
process.env.NODE_ENV
in the source code will not be replaced.import.meta.env.MODE
in the source code will be replaced with 'none'
.import.meta.env.DEV
in the source code will be replaced with false
.import.meta.env.PROD
in the source code will be replaced with false
.