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

# tools.bundlerChain

- **类型：**

```ts
type BundlerChainFn = (
  chain: RspackChain,
  utils: ModifyBundlerChainUtils,
) => Promise<void> | void;
```

- **默认值：** `undefined`

你可以通过 `tools.bundlerChain` 来修改默认的 Rspack 配置，它的值为 `Function` 类型，接收两个参数：

- 第一个参数为 `bundler-chain` 对象实例，你可以通过这个实例来修改 Rspack 的配置。
- 第二个参数为一个工具集合，包括`env`、`isProd`、`CHAIN_ID` 等。

:::tip 什么是 BundlerChain

Bundler chain 是基于 Rspack 配置 API 实现的链式配置工具，你可以用它来修改 Rspack 的配置。

通过 bundler chain 修改的配置，将在 Rspack 构建时生效。

:::

> `tools.bundlerChain` 的执行时机早于 tools.rspack，因此会被 tools.rspack 中的修改所覆盖。

更多信息可参考 [Rsbuild#tools.bundlerChain](https://v2.rsbuild.rs/zh/config/tools/bundler-chain)。
