diff --git a/packages/document/builder-doc/docs/en/config/output/dataUriLimit.md b/packages/document/builder-doc/docs/en/config/output/dataUriLimit.md index 266a4588f28d..7fe0cde4c9de 100644 --- a/packages/document/builder-doc/docs/en/config/output/dataUriLimit.md +++ b/packages/document/builder-doc/docs/en/config/output/dataUriLimit.md @@ -1,4 +1,4 @@ -- **Type** +- **Type:** ```ts type DataUriLimitConfig = { @@ -9,7 +9,7 @@ type DataUriLimitConfig = { }; ``` -- **Default** +- **Default:** ```js const defaultDatUriLimit = { diff --git a/packages/document/builder-doc/docs/en/config/output/distPath.md b/packages/document/builder-doc/docs/en/config/output/distPath.md index 94a688ffcadc..84c8f190d88a 100644 --- a/packages/document/builder-doc/docs/en/config/output/distPath.md +++ b/packages/document/builder-doc/docs/en/config/output/distPath.md @@ -1,4 +1,4 @@ -- **Type** +- **Type:** ```ts type DistPathConfig = { @@ -14,7 +14,7 @@ type DistPathConfig = { }; ``` -- **Default** +- **Default:** ```js const defaultDistPath = { diff --git a/packages/document/builder-doc/docs/en/config/output/filename.md b/packages/document/builder-doc/docs/en/config/output/filename.md index c659ca788bd9..e28c27d64cee 100644 --- a/packages/document/builder-doc/docs/en/config/output/filename.md +++ b/packages/document/builder-doc/docs/en/config/output/filename.md @@ -1,4 +1,4 @@ -- **Type** +- **Type:** ```ts type FilenameConfig = { @@ -11,7 +11,7 @@ type FilenameConfig = { }; ``` -- **Default** +- **Default:** ```js // Development diff --git a/packages/document/builder-doc/docs/en/config/output/svgDefaultExport.md b/packages/document/builder-doc/docs/en/config/output/svgDefaultExport.md index f551d6606e7f..ca55d6fc7517 100644 --- a/packages/document/builder-doc/docs/en/config/output/svgDefaultExport.md +++ b/packages/document/builder-doc/docs/en/config/output/svgDefaultExport.md @@ -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. diff --git a/packages/document/builder-doc/docs/en/config/tools/babel.md b/packages/document/builder-doc/docs/en/config/tools/babel.md index e0b8ff540d4d..33c850a7ed94 100644 --- a/packages/document/builder-doc/docs/en/config/tools/babel.md +++ b/packages/document/builder-doc/docs/en/config/tools/babel.md @@ -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 diff --git a/packages/document/builder-doc/docs/en/config/tools/rspack.md b/packages/document/builder-doc/docs/en/config/tools/rspack.md index 197e45c5feba..62435fd7644c 100644 --- a/packages/document/builder-doc/docs/en/config/tools/rspack.md +++ b/packages/document/builder-doc/docs/en/config/tools/rspack.md @@ -1,4 +1,4 @@ -- **Type:** `Object` | `Function` | `undefined` +- **Type:** `Object | Function | undefined` - **Default:** `undefined` - **Bundler:** `only support Rspack` @@ -6,7 +6,9 @@ ### 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 { @@ -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 { @@ -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 @@ -136,7 +142,7 @@ export default { }; ``` -### addRules +#### addRules - **Type:** `(rules: RuleSetRule | RuleSetRule[]) => void` @@ -170,7 +176,7 @@ export default { }; ``` -### prependPlugins +#### prependPlugins - **Type:** `(plugins: RspackPluginInstance | RspackPluginInstance[]) => void` @@ -190,7 +196,7 @@ export default { }; ``` -### appendPlugins +#### appendPlugins - **Type:** `(plugins: RspackPluginInstance | RspackPluginInstance[]) => void` @@ -210,7 +216,7 @@ export default { }; ``` -### removePlugin +#### removePlugin - **Type:** `(name: string) => void` @@ -228,7 +234,7 @@ export default { }; ``` -### mergeConfig +#### mergeConfig - **Type:** `(...configs: RspackConfig[]) => RspackConfig` @@ -246,7 +252,7 @@ export default { }; ``` -### getCompiledPath +#### getCompiledPath - **Type:** `(name: string) => string` diff --git a/packages/document/builder-doc/docs/en/config/tools/styledComponents.md b/packages/document/builder-doc/docs/en/config/tools/styledComponents.md index 9ba6a9ddf5ea..7216e3e8d3fe 100644 --- a/packages/document/builder-doc/docs/en/config/tools/styledComponents.md +++ b/packages/document/builder-doc/docs/en/config/tools/styledComponents.md @@ -1,5 +1,5 @@ - **Type:** `Object | Function` -- **Default** +- **Default:** ```js { diff --git a/packages/document/builder-doc/docs/en/config/tools/webpack.md b/packages/document/builder-doc/docs/en/config/tools/webpack.md index ba5326c782b0..7d184e2c2d5c 100644 --- a/packages/document/builder-doc/docs/en/config/tools/webpack.md +++ b/packages/document/builder-doc/docs/en/config/tools/webpack.md @@ -1,4 +1,4 @@ -- **Type:** `Object` | `Function` | `undefined` +- **Type:** `Object | Function | undefined` - **Default:** `undefined` - **Bundler:** `only support webpack` @@ -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 { @@ -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 { @@ -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'` @@ -155,7 +161,7 @@ export default { }; ``` -### HtmlWebpackPlugin +#### HtmlWebpackPlugin - **Type:** `typeof import('html-webpack-plugin')` @@ -171,7 +177,7 @@ export default { }; ``` -### addRules +#### addRules - **Type:** `(rules: RuleSetRule | RuleSetRule[]) => void` @@ -205,7 +211,7 @@ export default { }; ``` -### prependPlugins +#### prependPlugins - **Type:** `(plugins: WebpackPluginInstance | WebpackPluginInstance[]) => void` @@ -229,7 +235,7 @@ export default { }; ``` -### appendPlugins +#### appendPlugins - **Type:** `(plugins: WebpackPluginInstance | WebpackPluginInstance[]) => void` @@ -253,7 +259,7 @@ export default { }; ``` -### removePlugin +#### removePlugin - **Type:** `(name: string) => void` @@ -271,7 +277,7 @@ export default { }; ``` -### mergeConfig +#### mergeConfig - **Type:** `(...configs: WebpackConfig[]) => WebpackConfig` @@ -289,7 +295,7 @@ export default { }; ``` -### getCompiledPath +#### getCompiledPath - **Type:** `(name: string) => string` diff --git a/packages/document/builder-doc/docs/zh/config/output/dataUriLimit.md b/packages/document/builder-doc/docs/zh/config/output/dataUriLimit.md index bfa85132efd7..f9dc054acd3a 100644 --- a/packages/document/builder-doc/docs/zh/config/output/dataUriLimit.md +++ b/packages/document/builder-doc/docs/zh/config/output/dataUriLimit.md @@ -1,4 +1,4 @@ -- **类型** +- **类型:** ```ts type DataUriLimitConfig = { @@ -9,7 +9,7 @@ type DataUriLimitConfig = { }; ``` -- **默认值** +- **默认值:** ```js const defaultDatUriLimit = { diff --git a/packages/document/builder-doc/docs/zh/config/output/distPath.md b/packages/document/builder-doc/docs/zh/config/output/distPath.md index bb9b71af056d..6f0ea51e5d7b 100644 --- a/packages/document/builder-doc/docs/zh/config/output/distPath.md +++ b/packages/document/builder-doc/docs/zh/config/output/distPath.md @@ -1,4 +1,4 @@ -- **类型** +- **类型:** ```ts type DistPathConfig = { @@ -14,7 +14,7 @@ type DistPathConfig = { }; ``` -- **默认值** +- **默认值:** ```js const defaultDistPath = { diff --git a/packages/document/builder-doc/docs/zh/config/output/filename.md b/packages/document/builder-doc/docs/zh/config/output/filename.md index e808e83d2267..83325c94563c 100644 --- a/packages/document/builder-doc/docs/zh/config/output/filename.md +++ b/packages/document/builder-doc/docs/zh/config/output/filename.md @@ -1,4 +1,4 @@ -- **类型** +- **类型:** ```ts type FilenameConfig = { @@ -11,7 +11,7 @@ type FilenameConfig = { }; ``` -- **默认值** +- **默认值:** ```js // 开发环境 diff --git a/packages/document/builder-doc/docs/zh/config/output/svgDefaultExport.md b/packages/document/builder-doc/docs/zh/config/output/svgDefaultExport.md index 5504695ce2f7..2fa60f8e64e9 100644 --- a/packages/document/builder-doc/docs/zh/config/output/svgDefaultExport.md +++ b/packages/document/builder-doc/docs/zh/config/output/svgDefaultExport.md @@ -1,5 +1,5 @@ -- **类型:** `url` | `component` -- **默认值:** `url` +- **类型:** `'url' | 'component'` +- **默认值:** `'url'` `output.svgDefaultExport` 可以用来配置 SVG 文件的默认导出。 diff --git a/packages/document/builder-doc/docs/zh/config/tools/bundlerChain.mdx b/packages/document/builder-doc/docs/zh/config/tools/bundlerChain.mdx index be53cfc2849b..09dcd1dc72d5 100644 --- a/packages/document/builder-doc/docs/zh/config/tools/bundlerChain.mdx +++ b/packages/document/builder-doc/docs/zh/config/tools/bundlerChain.mdx @@ -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` 等。 diff --git a/packages/document/builder-doc/docs/zh/config/tools/rspack.md b/packages/document/builder-doc/docs/zh/config/tools/rspack.md index 3bce8fb88f7d..47fa45fbc999 100644 --- a/packages/document/builder-doc/docs/zh/config/tools/rspack.md +++ b/packages/document/builder-doc/docs/zh/config/tools/rspack.md @@ -1,4 +1,4 @@ -- **类型:** `Object` | `Function` | `undefined` +- **类型:** `Object | Function | undefined` - **默认值:** `undefined` - **打包工具:** `仅支持 Rspack` @@ -6,7 +6,9 @@ ### Object 类型 -你可以配置为一个对象,这个对象将会和原始的 Rspack 配置通过 [webpack-merge](https://github.com/survivejs/webpack-merge) 进行合并。比如: +`tools.rspack` 可以配置为一个对象,这个对象将会和内置的 Rspack 配置通过 [webpack-merge](https://github.com/survivejs/webpack-merge) 进行深层合并。 + +比如添加 `resolve.alias` 配置: ```js export default { @@ -24,7 +26,7 @@ export default { ### Function 类型 -你也可以配置为一个函数,这个函数接收一个参数,即原始的 Rspack 配置,你可以对这个配置进行修改,然后返回一个新的配置。比如: +`tools.rspack` 也可以配置为一个函数,这个函数接收一个参数,即内置的 Rspack 配置对象,你可以对这个对象进行修改,然后返回一份新的配置。比如: ```js export default { @@ -37,10 +39,14 @@ export default { }; ``` -这个函数的第二个参数是一个对象,包含了一些工具集合的信息。详情如下: +:::tip +`tools.rspack` 函数返回的对象会直接作为最终使用的 Rspack 配置,不会再与内置的 Rspack 配置进行合并。 +::: ### 工具集合 +这个函数的第二个参数是一个对象,包含了一些工具函数和属性,详情如下: + #### env - **类型:** `'development' | 'production' | 'test'` @@ -136,7 +142,7 @@ export default { }; ``` -### addRules +#### addRules - **类型:** `(rules: RuleSetRule | RuleSetRule[]) => void` @@ -170,7 +176,7 @@ export default { }; ``` -### prependPlugins +#### prependPlugins - **类型:** `(plugins: RspackPluginInstance | RspackPluginInstance[]) => void` @@ -190,7 +196,7 @@ export default { }; ``` -### appendPlugins +#### appendPlugins - **类型:** `(plugins: RspackPluginInstance | RspackPluginInstance[]) => void` @@ -210,7 +216,7 @@ export default { }; ``` -### removePlugin +#### removePlugin - **类型:** `(name: string) => void` @@ -228,7 +234,7 @@ export default { }; ``` -### mergeConfig +#### mergeConfig - **类型:** `(...configs: RspackConfig[]) => RspackConfig` @@ -246,7 +252,7 @@ export default { }; ``` -### getCompiledPath +#### getCompiledPath - **类型:** `(name: string) => string` diff --git a/packages/document/builder-doc/docs/zh/config/tools/styledComponents.md b/packages/document/builder-doc/docs/zh/config/tools/styledComponents.md index e589b72c6262..bca9aa782b62 100644 --- a/packages/document/builder-doc/docs/zh/config/tools/styledComponents.md +++ b/packages/document/builder-doc/docs/zh/config/tools/styledComponents.md @@ -1,5 +1,5 @@ - **类型:** `Object | Function` -- **默认值** +- **默认值:** ```js { diff --git a/packages/document/builder-doc/docs/zh/config/tools/webpack.md b/packages/document/builder-doc/docs/zh/config/tools/webpack.md index be98930f0579..1fdaaad20f92 100644 --- a/packages/document/builder-doc/docs/zh/config/tools/webpack.md +++ b/packages/document/builder-doc/docs/zh/config/tools/webpack.md @@ -1,4 +1,4 @@ -- **类型:** `Object` | `Function` | `undefined` +- **类型:** `Object | Function | undefined` - **默认值:** `undefined` - **打包工具:** `仅支持 webpack` @@ -8,7 +8,9 @@ ### Object 类型 -你可以配置为一个对象,这个对象将会和原始的 webpack 配置通过 [webpack-merge](https://github.com/survivejs/webpack-merge) 进行合并。比如: +`tools.webpack` 可以配置为一个对象,这个对象将会和内置的 webpack 配置通过 [webpack-merge](https://github.com/survivejs/webpack-merge) 进行深层合并。 + +比如添加 `resolve.alias` 配置: ```js export default { @@ -26,7 +28,7 @@ export default { ### Function 类型 -你也可以配置为一个函数,这个函数接收一个参数,即原始的 webpack 配置,你可以对这个配置进行修改,然后返回一个新的配置。比如: +`tools.webpack` 也可以配置为一个函数,这个函数的第一个入参为内置的 webpack 配置对象,你可以对这个对象进行修改,然后返回一份新的配置。比如: ```js export default { @@ -39,10 +41,14 @@ export default { }; ``` -这个函数的第二个参数是一个对象,包含了一些工具集合的信息。详情如下: +:::tip +`tools.webpack` 函数返回的对象会直接作为最终使用的 webpack 配置,不会再与内置的 webpack 配置进行合并。 +::: ### 工具集合 +这个函数的第二个参数是一个对象,包含了一些工具函数和属性,详情如下: + #### env - **类型:** `'development' | 'production' | 'test'` @@ -155,7 +161,7 @@ export default { }; ``` -### HtmlWebpackPlugin +#### HtmlWebpackPlugin - **类型:** `typeof import('html-webpack-plugin')` @@ -171,7 +177,7 @@ export default { }; ``` -### addRules +#### addRules - **类型:** `(rules: RuleSetRule | RuleSetRule[]) => void` @@ -205,7 +211,7 @@ export default { }; ``` -### prependPlugins +#### prependPlugins - **类型:** `(plugins: WebpackPluginInstance | WebpackPluginInstance[]) => void` @@ -229,7 +235,7 @@ export default { }; ``` -### appendPlugins +#### appendPlugins - **类型:** `(plugins: WebpackPluginInstance | WebpackPluginInstance[]) => void` @@ -253,7 +259,7 @@ export default { }; ``` -### removePlugin +#### removePlugin - **类型:** `(name: string) => void` @@ -271,7 +277,7 @@ export default { }; ``` -### mergeConfig +#### mergeConfig - **类型:** `(...configs: WebpackConfig[]) => WebpackConfig` @@ -289,7 +295,7 @@ export default { }; ``` -### getCompiledPath +#### getCompiledPath - **类型:** `(name: string) => string` diff --git a/packages/document/builder-doc/docs/zh/config/tools/webpackChain.md b/packages/document/builder-doc/docs/zh/config/tools/webpackChain.md index 154ce5efc0b9..d1ad64183534 100644 --- a/packages/document/builder-doc/docs/zh/config/tools/webpackChain.md +++ b/packages/document/builder-doc/docs/zh/config/tools/webpackChain.md @@ -2,7 +2,7 @@ - **默认值:** `undefined` - **打包工具:** `仅支持 webpack` -你可以通过 `tools.webpackChain` 来修改默认的 webpack 配置,值为 `Function` 类型,接收两个参数: +你可以通过 `tools.webpackChain` 来修改默认的 webpack 配置,它的值为 `Function` 类型,接收两个参数: - 第一个参数为 `webpack-chain` 对象实例,你可以通过这个实例来修改默认的 webpack 配置。 - 第二个参数为一个工具集合,包括`env`、`isProd`、`CHAIN_ID` 等。