Skip to content

Commit

Permalink
docs: LimitChunkCountPlugin docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind committed Apr 17, 2024
1 parent 5b4cc6d commit 18061ca
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
30 changes: 30 additions & 0 deletions website/docs/en/plugins/webpack/limit-chunk-count-plugin.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { ApiMeta } from '../../../../components/ApiMeta.tsx';
import WebpackLicense from '../../../../components/webpack-license';

<WebpackLicense from="https://webpack.js.org/plugins/limit-chunk-count-plugin/" />

# LimitChunkCountPlugin

<ApiMeta addedVersion={'0.3.10'} />

While writing your code, you may have already added many code split points to load stuff on demand. After compiling you might notice that some chunks are too small - creating larger HTTP overhead. `LimitChunkCountPlugin` can post-process your chunks by merging them.

```js
new rspack.optimize.LimitChunkCountPlugin({
// Options...
});
```

## Options

### maxChunks

- **Type:** `number`

Limit the maximum number of chunks using a value greater than or equal to `1`. Using `1` will prevent any additional chunks from being added as the entry/main chunk is also included in the count.

```js
new rspack.optimize.LimitChunkCountPlugin({
maxChunks: 5,
})
```
30 changes: 30 additions & 0 deletions website/docs/zh/plugins/webpack/limit-chunk-count-plugin.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { ApiMeta } from '../../../../components/ApiMeta.tsx';
import WebpackLicense from '../../../../components/webpack-license';

<WebpackLicense from="https://webpack.js.org/plugins/limit-chunk-count-plugin/" />

# LimitChunkCountPlugin

<ApiMeta addedVersion={'0.3.10'} />

在编写代码时,你可能已经添加了许多代码分割点以按需加载内容。在编译后,你可能会注意到有些 chunk 太小——造成了较大的 HTTP 开销。`LimitChunkCountPlugin` 可以在处理完毕后通过合并它们来优化你的 chunk。

```js
new rspack.optimize.LimitChunkCountPlugin({
// 选项...
});
```

## 选项

### maxChunks

- **类型:** `number`

通过使用大于或等于`1`的值来限制最大代码块数量。使用`1`将阻止添加任何额外的代码块,因为入口/主代码块也包含在计数中。

```js
new rspack.optimize.LimitChunkCountPlugin({
maxChunks: 5,
})
```

0 comments on commit 18061ca

Please sign in to comment.