Skip to content

Commit 1714ada

Browse files
authored
docs(builder): optimize the document of tools configurations (#3711)
1 parent 8a7d4d2 commit 1714ada

File tree

17 files changed

+88
-64
lines changed

17 files changed

+88
-64
lines changed

packages/document/builder-doc/docs/en/config/output/dataUriLimit.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- **Type**
1+
- **Type:**
22

33
```ts
44
type DataUriLimitConfig = {
@@ -9,7 +9,7 @@ type DataUriLimitConfig = {
99
};
1010
```
1111

12-
- **Default**
12+
- **Default:**
1313

1414
```js
1515
const defaultDatUriLimit = {

packages/document/builder-doc/docs/en/config/output/distPath.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- **Type**
1+
- **Type:**
22

33
```ts
44
type DistPathConfig = {
@@ -14,7 +14,7 @@ type DistPathConfig = {
1414
};
1515
```
1616

17-
- **Default**
17+
- **Default:**
1818

1919
```js
2020
const defaultDistPath = {

packages/document/builder-doc/docs/en/config/output/filename.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- **Type**
1+
- **Type:**
22

33
```ts
44
type FilenameConfig = {
@@ -11,7 +11,7 @@ type FilenameConfig = {
1111
};
1212
```
1313

14-
- **Default**
14+
- **Default:**
1515

1616
```js
1717
// Development

packages/document/builder-doc/docs/en/config/output/svgDefaultExport.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
- **Type:** `url` | `component`
2-
- **Default:** `url`
1+
- **Type:** `'url' | 'component'`
2+
- **Default:** `'url'`
33

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

packages/document/builder-doc/docs/en/config/tools/babel.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
- **Type:** `Object | Function`
22
- **Default:** `undefined`
33

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

66
:::warning
7-
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.
7+
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.
88
:::
99

1010
### Function Type

packages/document/builder-doc/docs/en/config/tools/rspack.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
- **Type:** `Object` | `Function` | `undefined`
1+
- **Type:** `Object | Function | undefined`
22
- **Default:** `undefined`
33
- **Bundler:** `only support Rspack`
44

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

77
### Object Type
88

9-
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:
9+
`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).
10+
11+
For example, add `resolve.alias` configuration:
1012

1113
```js
1214
export default {
@@ -24,7 +26,7 @@ export default {
2426

2527
### Function Type
2628

27-
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:
29+
`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:
2830

2931
```js
3032
export default {
@@ -37,7 +39,11 @@ export default {
3739
};
3840
```
3941

40-
The second parameter of this function is an object that contains some information about the tool collection. Details are as follows:
42+
:::tip
43+
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.
44+
:::
45+
46+
The second parameter of this function is an object, which contains some utility functions and properties, as follows:
4147

4248
### Utils
4349

@@ -136,7 +142,7 @@ export default {
136142
};
137143
```
138144

139-
### addRules
145+
#### addRules
140146

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

@@ -170,7 +176,7 @@ export default {
170176
};
171177
```
172178

173-
### prependPlugins
179+
#### prependPlugins
174180

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

@@ -190,7 +196,7 @@ export default {
190196
};
191197
```
192198

193-
### appendPlugins
199+
#### appendPlugins
194200

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

@@ -210,7 +216,7 @@ export default {
210216
};
211217
```
212218

213-
### removePlugin
219+
#### removePlugin
214220

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

@@ -228,7 +234,7 @@ export default {
228234
};
229235
```
230236

231-
### mergeConfig
237+
#### mergeConfig
232238

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

@@ -246,7 +252,7 @@ export default {
246252
};
247253
```
248254

249-
### getCompiledPath
255+
#### getCompiledPath
250256

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

packages/document/builder-doc/docs/en/config/tools/styledComponents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
- **Type:** `Object | Function`
2-
- **Default**
2+
- **Default:**
33

44
```js
55
{

packages/document/builder-doc/docs/en/config/tools/webpack.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- **Type:** `Object` | `Function` | `undefined`
1+
- **Type:** `Object | Function | undefined`
22
- **Default:** `undefined`
33
- **Bundler:** `only support webpack`
44

@@ -8,7 +8,9 @@
88
99
### Object Type
1010

11-
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:
11+
`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).
12+
13+
For example, add `resolve.alias` configuration:
1214

1315
```js
1416
export default {
@@ -26,7 +28,7 @@ export default {
2628

2729
### Function Type
2830

29-
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:
31+
`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:
3032

3133
```js
3234
export default {
@@ -39,10 +41,14 @@ export default {
3941
};
4042
```
4143

42-
The second parameter of this function is an object that contains some information about the tool collection. Details are as follows:
44+
:::tip
45+
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.
46+
:::
4347

4448
### Utils
4549

50+
The second parameter of this function is an object, which contains some utility functions and properties, as follows:
51+
4652
#### env
4753

4854
- **Type:** `'development' | 'production' | 'test'`
@@ -155,7 +161,7 @@ export default {
155161
};
156162
```
157163

158-
### HtmlWebpackPlugin
164+
#### HtmlWebpackPlugin
159165

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

@@ -171,7 +177,7 @@ export default {
171177
};
172178
```
173179

174-
### addRules
180+
#### addRules
175181

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

@@ -205,7 +211,7 @@ export default {
205211
};
206212
```
207213

208-
### prependPlugins
214+
#### prependPlugins
209215

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

@@ -229,7 +235,7 @@ export default {
229235
};
230236
```
231237

232-
### appendPlugins
238+
#### appendPlugins
233239

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

@@ -253,7 +259,7 @@ export default {
253259
};
254260
```
255261

256-
### removePlugin
262+
#### removePlugin
257263

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

@@ -271,7 +277,7 @@ export default {
271277
};
272278
```
273279

274-
### mergeConfig
280+
#### mergeConfig
275281

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

@@ -289,7 +295,7 @@ export default {
289295
};
290296
```
291297

292-
### getCompiledPath
298+
#### getCompiledPath
293299

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

packages/document/builder-doc/docs/zh/config/output/dataUriLimit.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- **类型**
1+
- **类型**
22

33
```ts
44
type DataUriLimitConfig = {
@@ -9,7 +9,7 @@ type DataUriLimitConfig = {
99
};
1010
```
1111

12-
- **默认值**
12+
- **默认值**
1313

1414
```js
1515
const defaultDatUriLimit = {

packages/document/builder-doc/docs/zh/config/output/distPath.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- **类型**
1+
- **类型**
22

33
```ts
44
type DistPathConfig = {
@@ -14,7 +14,7 @@ type DistPathConfig = {
1414
};
1515
```
1616

17-
- **默认值**
17+
- **默认值**
1818

1919
```js
2020
const defaultDistPath = {

0 commit comments

Comments
 (0)