You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -19,18 +19,13 @@ Configure whether to enable code minification in production mode, or to configur
19
19
20
20
By default, JS and CSS code will be automatically minimized in production mode to improve page performance. If you do not want to minify the code, you can set `minify` to `false` to disable minification for all code. Alternatively, you can control the behavior of code minification through detailed configuration of the `minify` option. Below are detailed explanations for each configuration option:
21
21
22
-
Here are explanations for each field:
23
-
24
-
-`js`: Whether to enable minification for JavaScript code.
25
-
-`jsOptions`: JS code minification configuration, which will be merged with the default configuration and passed to SWC.
26
-
-`css`: Whether to enable minification for CSS code.
27
-
-`cssOptions`: CSS code minification configuration, which will be merged with the default configuration and passed to Lightning CSS.
28
-
29
22
## Example
30
23
31
-
### Disable all minification
24
+
### Disable minification
32
25
33
-
```js
26
+
Set `minify` to `false` to disable JS and CSS code minification:
27
+
28
+
```ts title="rsbuild.config.ts"
34
29
exportdefault {
35
30
output: {
36
31
minify: false,
@@ -39,12 +34,21 @@ export default {
39
34
```
40
35
41
36
:::tip
42
-
This configuration is usually used for debugging and troubleshooting. It is not recommended to disable code minification in production builds, as it will significantly degrade the page performance.
37
+
This usage is usually used for debugging and troubleshooting. It is not recommended to disable code minification in production builds, as it will significantly degrade the page performance.
43
38
:::
44
39
45
-
### Disable JavaScript minification
40
+
## Options
41
+
42
+
### minify.js
43
+
44
+
-**Type:**`boolean`
45
+
-**Default:**`mode === 'production'`
46
+
47
+
Whether to enable minification for JavaScript code.
`output.minify.jsOptions` is used to configure SWC's minification options. For detailed configurations, please refer to [SwcJsMinimizerRspackPlugin](https://rspack.dev/plugins/rspack/swc-js-minimizer-rspack-plugin). The following configuration will override the default settings, disable the mangle feature.
60
67
61
-
```js
68
+
For example, disable the mangle feature:
69
+
70
+
```ts title="rsbuild.config.ts"
62
71
exportdefault {
63
72
output: {
64
73
minify: {
@@ -74,11 +83,35 @@ export default {
74
83
75
84
> Refer to [Configure SWC](/guide/basic/configure-swc) for more details.
-**Default:** inherit from [tools.lightningcssLoader](/config/tools/lightningcss-loader)
78
109
79
110
`output.minify.cssOptions` is used to configure Lightning CSS's minification options. For specific configuration items, please refer to [LightningCssMinimizerRspackPlugin Documentation](https://rspack.dev/plugins/rspack/lightning-css-minimizer-rspack-plugin).
80
111
81
-
```js
112
+
For example, disable error recovery:
113
+
114
+
```ts title="rsbuild.config.ts"
82
115
exportdefault {
83
116
output: {
84
117
minify: {
@@ -91,3 +124,7 @@ export default {
91
124
},
92
125
};
93
126
```
127
+
128
+
:::tip
129
+
When you configure some options in [tools.lightningcssLoader](/config/tools/lightningcss-loader), `output.minify.cssOptions` will automatically inherit these options, which ensures that the CSS code transformation behavior in the development build is consistent with that in the production build.
0 commit comments