Skip to content

Commit d0a3f11

Browse files
authored
docs: specify minify for umd format (#1064)
1 parent 04eacd4 commit d0a3f11

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

website/docs/en/config/rsbuild/output.mdx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ Whether to generate a manifest file that contains information of all assets, and
123123

124124
## output.minify <RsbuildDocBadge path="/config/output/minify" text="output.minify" />
125125

126-
Configure whether to enable code minification in production mode, or to configure minimizer options.
126+
Configure whether to enable code minification, or to configure minimizer options.
127127

128128
When `output.minify` is not specified, Rslib will use a sane default value.
129129

130-
- When format is `esm`, `cjs` and `umd`, only dead code elimination and unused code elimination will be performed. The default value is:
130+
- When format is `esm` or `cjs`, only dead code elimination and unused code elimination will be performed. The default value is:
131131

132132
```ts
133133
export default defineConfig({
@@ -156,6 +156,16 @@ export default defineConfig({
156156
});
157157
```
158158

159+
- When format is `umd`, the default value is the same as above, only dead code elimination and unused code elimination will be performed, which is usually used to generate UMD output for development. If you need to generate UMD output for production with the smallest possible bundle size, you can set `output.minify` to true:
160+
161+
```ts
162+
export default defineConfig({
163+
output: {
164+
minify: true,
165+
},
166+
});
167+
```
168+
159169
- When format is `mf`, since MF assets are loaded over the network, which means they will not be compressed by the application project. Therefore, they need to be minified in Rslib. The default value is:
160170

161171
```ts

website/docs/zh/config/rsbuild/output.mdx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ Rslib 默认会根据 [format](/config/lib/format) 设置 `output.filename.js`
119119

120120
## output.minify <RsbuildDocBadge path="/config/output/minify" text="output.minify" />
121121

122-
用于设置是否在生产模式下开启代码压缩,或是配置压缩工具的选项
122+
用于设置是否开启代码压缩,以及配置压缩工具的选项
123123

124124
在未指定 `output.minify` 时,Rslib 会使用一个合理的默认值。
125125

126-
- format 为 `esm`, `cjs` 以及 `umd` 时,只会执行死代码消除和未使用代码消除,默认值为:
126+
- format 为 `esm``cjs` 时,仅会执行死代码消除和未使用代码消除,默认值为:
127127

128128
```ts
129129
export default defineConfig({
@@ -152,7 +152,17 @@ export default defineConfig({
152152
});
153153
```
154154

155-
- 在 format 为 `mf` 时,由于 MF 资源通过网络加载,这意味着它们不会被应用项目压缩。因此,需要在 Rslib 中对它们进行压缩。默认值为:
155+
- 当 format 为 `umd` 时,默认值同上,仅会执行死代码消除和未使用代码消除,这通常用于生成开发环境的 UMD 产物。如果需要生成体积尽可能小的生产环境的 UMD 产物,可以将 `output.minify` 设置为 true:
156+
157+
```ts
158+
export default defineConfig({
159+
output: {
160+
minify: true,
161+
},
162+
});
163+
```
164+
165+
- 当 format 为 `mf` 时,由于 MF 资源通过网络加载,这意味着它们不会被应用项目压缩。因此,需要在 Rslib 中对它们进行压缩。默认值为:
156166

157167
```ts
158168
export default defineConfig({

0 commit comments

Comments
 (0)