> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# LimitChunkCountPlugin

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.

## Examples

Limit the compilation to five chunks:

```js title="rspack.config.mjs"
import { rspack } from '@rspack/core';

export default {
  plugins: [
    new rspack.optimize.LimitChunkCountPlugin({
      maxChunks: 5,
    }),
  ],
};
```

## 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,
});
```


This page is adapted from [webpack documentation](https://webpack.js.org/plugins/limit-chunk-count-plugin/) under the [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), with modifications.

