Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions website/docs/en/config/rsbuild/output.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ Whether to generate a manifest file that contains information of all assets, and

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

Configure whether to enable code minification in production mode, or to configure minimizer options.
Configure whether to enable code minification, or to configure minimizer options.

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

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

```ts
export default defineConfig({
Expand Down Expand Up @@ -156,6 +156,16 @@ export default defineConfig({
});
```

- 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:

```ts
export default defineConfig({
output: {
minify: true,
},
});
```

- 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:

```ts
Expand Down
16 changes: 13 additions & 3 deletions website/docs/zh/config/rsbuild/output.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ Rslib 默认会根据 [format](/config/lib/format) 设置 `output.filename.js`

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

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

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

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

```ts
export default defineConfig({
Expand Down Expand Up @@ -152,7 +152,17 @@ export default defineConfig({
});
```

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

```ts
export default defineConfig({
output: {
minify: true,
},
});
```

- 当 format 为 `mf` 时,由于 MF 资源通过网络加载,这意味着它们不会被应用项目压缩。因此,需要在 Rslib 中对它们进行压缩。默认值为:

```ts
export default defineConfig({
Expand Down
Loading