true
Controls code minification in production mode and configures minimizer options.
JavaScript and CSS code are automatically minified in production mode to improve page performance. To disable minification entirely, set minify
to false
. Control specific minification behavior using the detailed minify
options:
Rsbuild uses SWC to minify JavaScript code and Lightning CSS to minify CSS code by default.
Set minify
to false
to disable JavaScript and CSS code minification:
This helps with debugging and troubleshooting. We don't recommend disabling code minification in production builds, as it significantly impacts page performance.
boolean | 'always'
true
Whether to enable minification for JavaScript bundles:
true
: Enabled in production mode.false
: Disabled in all modes.'always'
: Enabled in all modes.For example, to disable JavaScript minification:
To enable JavaScript minification in both development and production mode:
Rspack.SwcJsMinimizerRspackPluginOptions
{}
output.minify.jsOptions
configures SWC's minification options. See SwcJsMinimizerRspackPlugin for detailed configuration options.
For example, disable the mangle feature:
Refer to Configure SWC for more details.
boolean | 'always'
true
Whether to enable minification for CSS bundles:
true
: Enabled in production mode.false
: Disabled in all modes.'always'
: Enabled in all modes.For example, disable CSS minification:
Enable CSS minification in both development and production mode:
Rspack.LightningcssMinimizerRspackPluginOptions
output.minify.cssOptions
configures Lightning CSS's minification options. See LightningCssMinimizerRspackPlugin Documentation for detailed configuration options.
For example, disable error recovery:
When you configure options in tools.lightningcssLoader, output.minify.cssOptions
will automatically inherit these options, ensuring that CSS code transformation behavior in the development build is consistent with the production build.
If the default SWC minifier doesn't meet your needs, you can switch to other minifiers using the tools.bundlerChain option.
For example, use terser-webpack-plugin to switch to Terser or esbuild.
esbuild
package and set esbuildMinify
:
When using a custom JS minifier, the minify.jsOptions
option will no longer take effect.