Home > @lynx-js/rspeedy > Config > mode
Specify the build mode for Rsbuild and Rspack, as each mode has different default behavior and optimizations.
Signature:
The default value of mode depends on the process.env.NODE_ENV environment variable:
If NODE_ENV is production, the default value is production.
If NODE_ENV is development, the default value is development.
If 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 Rspeedy's CLI:
rspeedy dev and rspeedy preview will set the default values of NODE_ENV and mode to 'development'.
rspeedy build will set the default values of NODE_ENV and mode to 'production'.
If the value of mode is 'development':
Enable HMR and register the HotModuleReplacementPlugin.
Generate JavaScript source maps, but do not generate CSS source maps. See Output.sourceMap for details.
The process.env.NODE_ENV in the source code will be replaced with 'development'.
The import.meta.env.MODE in the source code will be replaced with 'development'.
The import.meta.env.DEV in the source code will be replaced with true.
The import.meta.env.PROD in the source code will be replaced with false.
If the value of mode is 'production':
Enable JavaScript code minification and register the SwcJsMinimizerRspackPlugin.
Generated JavaScript and CSS filenames will have hash suffixes, see Output.filenameHash.
Generated CSS Modules classnames will be shorter, see CssModules.localIdentName.
Do not generate JavaScript and CSS source maps, see Output.sourceMap.
The process.env.NODE_ENV in the source code will be replaced with 'production'.
The import.meta.env.MODE in the source code will be replaced with 'production'.
The import.meta.env.DEV in the source code will be replaced with false.
The import.meta.env.PROD in the source code will be replaced with true.