Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: improve bundler chain document #1120

Merged
merged 1 commit into from
Dec 29, 2023
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
26 changes: 17 additions & 9 deletions packages/document/docs/en/config/tools/bundler-chain.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# bundlerChain

- **Type:** `Function | undefined`
- **Type:**

```ts
type BundlerChainFn = (
chain: BundlerChain,
utils: ModifyBundlerChainUtils,
) => void;
```

- **Default:** `undefined`

You can modify the Rspack and webpack configuration by configuring `tools.bundlerChain` which is type of `Function`. The function receives two parameters, the first is the original bundler chain object, and the second is an object containing some utils.
Expand All @@ -15,9 +23,9 @@ Configurations modified via bundler chain will work on both Rspack and webpack b

> `tools.bundlerChain` is executed earlier than tools.rspack and thus will be overridden by changes in other.

### Utils
## Utils

#### env
### env

- **Type:** `'development' | 'production' | 'test'`

Expand All @@ -35,7 +43,7 @@ export default {
};
```

#### isProd
### isProd

- **Type:** `boolean`

Expand All @@ -53,7 +61,7 @@ export default {
};
```

#### target
### target

- **Type:** `'web' | 'node' | 'web-worker' | 'service-worker'`

Expand All @@ -71,7 +79,7 @@ export default {
};
```

#### isServer
### isServer

- **Type:** `boolean`

Expand All @@ -89,7 +97,7 @@ export default {
};
```

#### isWebWorker
### isWebWorker

- **Type:** `boolean`

Expand Down Expand Up @@ -123,7 +131,7 @@ export default {
};
```

#### CHAIN_ID
## CHAIN_ID

Some common Chain IDs are predefined in the Rsbuild, and you can use these IDs to locate the built-in Rule or Plugin.

Expand All @@ -133,7 +141,7 @@ Please note that some of the rules or plugins listed below are not available by
For example, the `RULE.STYLUS` rule exists only when the Stylus plugin is registered.
:::

##### CHAIN_ID.RULE
### CHAIN_ID.RULE

| ID | Description |
| ------------- | ----------------- |
Expand Down
3 changes: 1 addition & 2 deletions packages/document/docs/en/config/tools/rspack.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# rspack

- **Type:** `Object | Function | undefined`
- **Type:** `Rspack.Configuration | Function | undefined`
- **Default:** `undefined`
- **Bundler:** `only support Rspack`

`tools.rspack` is used to configure [Rspack](https://rspack.dev/).

Expand Down
26 changes: 17 additions & 9 deletions packages/document/docs/zh/config/tools/bundler-chain.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# bundlerChain

- **类型:** `Function | undefined`
- **类型:**

```ts
type BundlerChainFn = (
chain: BundlerChain,
utils: ModifyBundlerChainUtils,
) => void;
```

- **默认值:** `undefined`

你可以通过 `tools.bundlerChain` 来修改默认的 Rspack 和 webpack 配置,它的值为 `Function` 类型,接收两个参数:
Expand All @@ -18,9 +26,9 @@ Bundler chain 是 webpack chain 的子集,其中包含一部分 webpack chain

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

### 工具集合
## 工具集合

#### env
### env

- **类型:** `'development' | 'production' | 'test'`

Expand All @@ -38,7 +46,7 @@ export default {
};
```

#### isProd
### isProd

- **类型:** `boolean`

Expand All @@ -56,7 +64,7 @@ export default {
};
```

#### target
### target

- **类型:** `'web' | 'node' | 'web-worker' | 'service-worker'`

Expand All @@ -74,7 +82,7 @@ export default {
};
```

#### isServer
### isServer

- **类型:** `boolean`

Expand All @@ -92,7 +100,7 @@ export default {
};
```

#### isWebWorker
### isWebWorker

- **类型:** `boolean`

Expand Down Expand Up @@ -126,7 +134,7 @@ export default {
};
```

#### CHAIN_ID
## CHAIN_ID

Rsbuild 中预先定义了一些常用的 Chain ID,你可以通过这些 ID 来定位到内置的 Rule 或 Plugin。

Expand All @@ -136,7 +144,7 @@ Rsbuild 中预先定义了一些常用的 Chain ID,你可以通过这些 ID
比如,`RULE.STYLUS` 仅在注册了 Stylus 插件后才会存在。
:::

##### CHAIN_ID.RULE
### CHAIN_ID.RULE

| ID | 描述 |
| ------------- | -------------------- |
Expand Down
3 changes: 1 addition & 2 deletions packages/document/docs/zh/config/tools/rspack.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# rspack

- **类型:** `Object | Function | undefined`
- **类型:** `Rspack.Configuration | Function | undefined`
- **默认值:** `undefined`
- **打包工具:** `仅支持 Rspack`

`tools.rspack` 选项用于配置原生的 [Rspack](https://rspack.dev/)。

Expand Down