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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- **Type**
- **Type:**

```ts
type DataUriLimitConfig = {
Expand All @@ -9,7 +9,7 @@ type DataUriLimitConfig = {
};
```

- **Default**
- **Default:**

```js
const defaultDatUriLimit = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- **Type**
- **Type:**

```ts
type DistPathConfig = {
Expand All @@ -14,7 +14,7 @@ type DistPathConfig = {
};
```

- **Default**
- **Default:**

```js
const defaultDistPath = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- **Type**
- **Type:**

```ts
type FilenameConfig = {
Expand All @@ -11,7 +11,7 @@ type FilenameConfig = {
};
```

- **Default**
- **Default:**

```js
// Development
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- **Type:** `url` | `component`
- **Default:** `url`
- **Type:** `'url' | 'component'`
- **Default:** `'url'`

`output.svgDefaultExport` is used to configure the default export type of SVG files.

Expand Down
4 changes: 2 additions & 2 deletions packages/document/builder-doc/docs/en/config/tools/babel.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
- **Type:** `Object | Function`
- **Default:** `undefined`

By `tools.babel` you can modify the options of [babel-loader](https://github.com/babel/babel-loader).
With `tools.babel` you can modify the options of [babel-loader](https://github.com/babel/babel-loader).

:::warning
When using Rspack as a packaging tool, using this configuration item will slow down Rspack builds a bit. Because Rspack uses SWC compilation by default, there will be additional compilation overhead when configuring the Babel.
When using Rspack as the bundler, using this configuration will slow down the build speed of Rspack. As Rspack uses SWC compilation by default, there will be additional compilation overhead when using the Babel.
:::

### Function Type
Expand Down
26 changes: 16 additions & 10 deletions packages/document/builder-doc/docs/en/config/tools/rspack.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
- **Type:** `Object` | `Function` | `undefined`
- **Type:** `Object | Function | undefined`
- **Default:** `undefined`
- **Bundler:** `only support Rspack`

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

### Object Type

You can configure it as an object, which will be merged with the original Rspack configuration through [webpack-merge](https://github.com/survivejs/webpack-merge). For example:
`tools.rspack` can be configured as an object to be deep merged with the built-in Rspack configuration through [webpack-merge](https://github.com/survivejs/webpack-merge).

For example, add `resolve.alias` configuration:

```js
export default {
Expand All @@ -24,7 +26,7 @@ export default {

### Function Type

You can also configure it as a function, which accepts one parameter, the original Rspack configuration, you can modify this configuration, and then return a new configuration. For example:
`tools.rspack` can be configured as a function. The first parameter of this function is the built-in Rspack configuration object, you can modify this object, and then return it. For example:

```js
export default {
Expand All @@ -37,7 +39,11 @@ export default {
};
```

The second parameter of this function is an object that contains some information about the tool collection. Details are as follows:
:::tip
The object returned by the `tools.rspack` function is used directly as the final Rspack configuration and is not merged with the built-in Rspack configuration.
:::

The second parameter of this function is an object, which contains some utility functions and properties, as follows:

### Utils

Expand Down Expand Up @@ -136,7 +142,7 @@ export default {
};
```

### addRules
#### addRules

- **Type:** `(rules: RuleSetRule | RuleSetRule[]) => void`

Expand Down Expand Up @@ -170,7 +176,7 @@ export default {
};
```

### prependPlugins
#### prependPlugins

- **Type:** `(plugins: RspackPluginInstance | RspackPluginInstance[]) => void`

Expand All @@ -190,7 +196,7 @@ export default {
};
```

### appendPlugins
#### appendPlugins

- **Type:** `(plugins: RspackPluginInstance | RspackPluginInstance[]) => void`

Expand All @@ -210,7 +216,7 @@ export default {
};
```

### removePlugin
#### removePlugin

- **Type:** `(name: string) => void`

Expand All @@ -228,7 +234,7 @@ export default {
};
```

### mergeConfig
#### mergeConfig

- **Type:** `(...configs: RspackConfig[]) => RspackConfig`

Expand All @@ -246,7 +252,7 @@ export default {
};
```

### getCompiledPath
#### getCompiledPath

- **Type:** `(name: string) => string`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- **Type:** `Object | Function`
- **Default**
- **Default:**

```js
{
Expand Down
28 changes: 17 additions & 11 deletions packages/document/builder-doc/docs/en/config/tools/webpack.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- **Type:** `Object` | `Function` | `undefined`
- **Type:** `Object | Function | undefined`
- **Default:** `undefined`
- **Bundler:** `only support webpack`

Expand All @@ -8,7 +8,9 @@

### Object Type

You can configure it as an object, which will be merged with the original webpack configuration through [webpack-merge](https://github.com/survivejs/webpack-merge). For example:
`tools.webpack` can be configured as an object to be deep merged with the built-in webpack configuration through [webpack-merge](https://github.com/survivejs/webpack-merge).

For example, add `resolve.alias` configuration:

```js
export default {
Expand All @@ -26,7 +28,7 @@ export default {

### Function Type

You can also configure it as a function, which accepts one parameter, the original webpack configuration, you can modify this configuration, and then return a new configuration. For example:
`tools.webpack` can be configured as a function. The first parameter of this function is the built-in webpack configuration object, you can modify this object, and then return it. For example:

```js
export default {
Expand All @@ -39,10 +41,14 @@ export default {
};
```

The second parameter of this function is an object that contains some information about the tool collection. Details are as follows:
:::tip
The object returned by the `tools.webpack` function is used directly as the final webpack configuration and is not merged with the built-in webpack configuration.
:::

### Utils

The second parameter of this function is an object, which contains some utility functions and properties, as follows:

#### env

- **Type:** `'development' | 'production' | 'test'`
Expand Down Expand Up @@ -155,7 +161,7 @@ export default {
};
```

### HtmlWebpackPlugin
#### HtmlWebpackPlugin

- **Type:** `typeof import('html-webpack-plugin')`

Expand All @@ -171,7 +177,7 @@ export default {
};
```

### addRules
#### addRules

- **Type:** `(rules: RuleSetRule | RuleSetRule[]) => void`

Expand Down Expand Up @@ -205,7 +211,7 @@ export default {
};
```

### prependPlugins
#### prependPlugins

- **Type:** `(plugins: WebpackPluginInstance | WebpackPluginInstance[]) => void`

Expand All @@ -229,7 +235,7 @@ export default {
};
```

### appendPlugins
#### appendPlugins

- **Type:** `(plugins: WebpackPluginInstance | WebpackPluginInstance[]) => void`

Expand All @@ -253,7 +259,7 @@ export default {
};
```

### removePlugin
#### removePlugin

- **Type:** `(name: string) => void`

Expand All @@ -271,7 +277,7 @@ export default {
};
```

### mergeConfig
#### mergeConfig

- **Type:** `(...configs: WebpackConfig[]) => WebpackConfig`

Expand All @@ -289,7 +295,7 @@ export default {
};
```

### getCompiledPath
#### getCompiledPath

- **Type:** `(name: string) => string`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- **类型**
- **类型**

```ts
type DataUriLimitConfig = {
Expand All @@ -9,7 +9,7 @@ type DataUriLimitConfig = {
};
```

- **默认值**
- **默认值**

```js
const defaultDatUriLimit = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- **类型**
- **类型**

```ts
type DistPathConfig = {
Expand All @@ -14,7 +14,7 @@ type DistPathConfig = {
};
```

- **默认值**
- **默认值**

```js
const defaultDistPath = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- **类型**
- **类型**

```ts
type FilenameConfig = {
Expand All @@ -11,7 +11,7 @@ type FilenameConfig = {
};
```

- **默认值**
- **默认值**

```js
// 开发环境
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- **类型:** `url` | `component`
- **默认值:** `url`
- **类型:** `'url' | 'component'`
- **默认值:** `'url'`

`output.svgDefaultExport` 可以用来配置 SVG 文件的默认导出。

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- **类型:** `Function | undefined`
- **默认值:** `undefined`

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

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