From 0a06c952f25883a5519c69a3bd001457655ff213 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 9 Dec 2024 16:19:45 +0800 Subject: [PATCH 1/3] docs: translate --- website/docs/en/config/rsbuild/index.mdx | 7 +++--- website/docs/en/config/rsbuild/tools.mdx | 4 +-- website/docs/zh/config/rsbuild/index.mdx | 16 ++++++++++++ website/docs/zh/config/rsbuild/tools.mdx | 32 ++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 5 deletions(-) diff --git a/website/docs/en/config/rsbuild/index.mdx b/website/docs/en/config/rsbuild/index.mdx index 93d0ee943..d8b453ea0 100644 --- a/website/docs/en/config/rsbuild/index.mdx +++ b/website/docs/en/config/rsbuild/index.mdx @@ -11,7 +11,8 @@ To learn more about Rslib configurations, check out [Configure Rslib](/guide/bas ## Overview -- [source](/config/rsbuild/source): Configure the source code parsing and compilation options. -- [output](/config/rsbuild/output): Configure the build outputs. -- [tools](/config/rsbuild/tools): Configure the low-level tools. +- [resolve](/config/rsbuild/resolve): Options for module resolution. +- [source](/config/rsbuild/source): Options for input source code. +- [output](/config/rsbuild/output): Options for build outputs. +- [tools](/config/rsbuild/tools): Options for low-level tools. - [plugins](/config/rsbuild/plugins): Configure Rsbuild plugins. diff --git a/website/docs/en/config/rsbuild/tools.mdx b/website/docs/en/config/rsbuild/tools.mdx index cae246ad6..c93e8ecac 100644 --- a/website/docs/en/config/rsbuild/tools.mdx +++ b/website/docs/en/config/rsbuild/tools.mdx @@ -2,11 +2,11 @@ import { RsbuildDocBadge } from '@components/RsbuildDocBadge'; # tools -Configure the low-level tools. +Options for low-level tools. ## tools.bundlerChain -[rspack-chain](https://github.com/rspack-contrib/rspack-chain) is a utility library for configuring Rspack. +[rspack-chain](https://github.com/rspack-contrib/rspack-chain) is a utility library for configuring Rspack. By using `rspack-chain`, you can more easily modify and extend Rspack configurations. {/* ## tools.cssExtract */} diff --git a/website/docs/zh/config/rsbuild/index.mdx b/website/docs/zh/config/rsbuild/index.mdx index 6c0b6b446..6bcb06599 100644 --- a/website/docs/zh/config/rsbuild/index.mdx +++ b/website/docs/zh/config/rsbuild/index.mdx @@ -1 +1,17 @@ +import { RsbuildDocBadge } from '@components/RsbuildDocBadge'; + # Rsbuild 配置 + +Rslib 继承了 Rsbuild 的配置,所以你也可以配置 选项。本章节介绍了一些常见的配置项,并解释了如何在 Rslib 中使用它们。 + +:::tip +要了解更多关于 Rslib 的配置,请查看 [Configure Rslib](/guide/basic/configure-rslib)。 +::: + +## 概览 + +- [resolve](/config/rsbuild/resolve): 与模块解析相关的选项。 +- [source](/config/rsbuild/source): 与输入的源代码相关的选项。 +- [output](/config/rsbuild/output): 与构建产物相关的选项。 +- [tools](/config/rsbuild/tools): 与底层工具相关的选项。 +- [plugins](/config/rsbuild/plugins): 配置 Rsbuild 插件。 diff --git a/website/docs/zh/config/rsbuild/tools.mdx b/website/docs/zh/config/rsbuild/tools.mdx index 896a03e8d..84b17e99a 100644 --- a/website/docs/zh/config/rsbuild/tools.mdx +++ b/website/docs/zh/config/rsbuild/tools.mdx @@ -1 +1,33 @@ +import { RsbuildDocBadge } from '@components/RsbuildDocBadge'; + # tools + +与底层工具相关的选项。 + +## tools.bundlerChain + +[rspack-chain](https://github.com/rspack-contrib/rspack-chain) 是一个用于配置 Rspack 的工具库,通过 `tools.bundlerChain` 可以调用 `rspack-chain` 以修改默认的 Rspack 配置。 + +## tools.cssLoader + +Rsbuild 默认使用 [css-loader](https://github.com/webpack-contrib/css-loader) 来处理 CSS 资源。你可以通过 `tools.cssLoader` 来修改 css-loader 的选项。 + +## tools.lightningcssLoader + +通过 `tools.lightningcssLoader` 可以设置 [builtin:lightningcss-loader](https://rspack.dev/guide/features/builtin-lightningcss-loader) 的选项。 + +## tools.postcss + +Rsbuild 默认集成 PostCSS,你可以通过 `tools.postcss` 对 [postcss-loader](https://github.com/webpack-contrib/postcss-loader) 进行配置。 + +## tools.rspack + +`tools.rspack` 选项用于修改 [Rspack](https://rspack.dev/) 的配置项。 + +## tools.styleLoader + +通过 `tools.styleLoader` 可以设置 [style-loader](https://github.com/webpack-contrib/style-loader) 的配置项。 + +## tools.swc + +通过 `tools.swc` 可以设置 [builtin:swc-loader](https://rspack.dev/guide/features/builtin-swc-loader) 的选项。 From f70a6cc61c3358b6b9abf2349123733089d59960 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 9 Dec 2024 16:38:58 +0800 Subject: [PATCH 2/3] docs: translate Rsbuild configurations --- website/docs/en/config/rsbuild/output.mdx | 2 +- website/docs/en/config/rsbuild/resolve.mdx | 12 ++- website/docs/en/config/rsbuild/source.mdx | 6 +- website/docs/zh/config/rsbuild/output.mdx | 90 ++++++++++++++++++++++ website/docs/zh/config/rsbuild/resolve.mdx | 57 ++++++++++++++ website/docs/zh/config/rsbuild/source.mdx | 40 ++++++++++ 6 files changed, 200 insertions(+), 7 deletions(-) diff --git a/website/docs/en/config/rsbuild/output.mdx b/website/docs/en/config/rsbuild/output.mdx index aa5f37401..ccfa5a8c7 100644 --- a/website/docs/en/config/rsbuild/output.mdx +++ b/website/docs/en/config/rsbuild/output.mdx @@ -2,7 +2,7 @@ import { RsbuildDocBadge } from '@components/RsbuildDocBadge'; # output -Configure the build outputs. +Options for build outputs. {/* ## output.assetPrefix */} diff --git a/website/docs/en/config/rsbuild/resolve.mdx b/website/docs/en/config/rsbuild/resolve.mdx index 7f857f13d..9d692e163 100644 --- a/website/docs/en/config/rsbuild/resolve.mdx +++ b/website/docs/en/config/rsbuild/resolve.mdx @@ -2,9 +2,11 @@ import { RsbuildDocBadge } from '@components/RsbuildDocBadge'; # resolve +Options for module resolution. + ## resolve.aliasStrategy -`resolve.aliasStrategy` is used to control the priority between the `paths` option in `tsconfig.json` and the `alias` option in the bundler. +Control the priority between the `paths` option in `tsconfig.json` and the `resolve.alias` option of Rsbuild. ## resolve.alias @@ -14,7 +16,7 @@ It is important to note that `resolve.alias` differs from [output.externals](/co - `resolve.alias` allows you to replace the target module you want to include in the output bundles with another module. It only works if [lib.bundle](/config/lib/bundle) is set to `true`. - For example, if you want to replace `lodash` with `lodash-es` in a bundled CLI application, you can configure it as follows: + For example, if you want to replace `lodash` with `lodash-es` when bundling a package, you can configure it as follows: ```ts title="rslib.config.ts" export default { @@ -49,4 +51,8 @@ It is important to note that `resolve.alias` differs from [output.externals](/co ## resolve.dedupe -`resolve.dedupe` is used to resolve the specified packages from project root, which is useful for deduplicating packages and reducing the bundle size. +Force Rsbuild to resolve the specified packages from project root, which is useful for deduplicating packages and reducing the bundle size. + +## resolve.extensions + +Automatically resolve file extensions when importing modules. This means you can import files without explicitly writing their extensions. diff --git a/website/docs/en/config/rsbuild/source.mdx b/website/docs/en/config/rsbuild/source.mdx index edb9f9e2d..574a4c8e6 100644 --- a/website/docs/en/config/rsbuild/source.mdx +++ b/website/docs/en/config/rsbuild/source.mdx @@ -3,7 +3,7 @@ import { RsbuildDocBadge } from '@components/RsbuildDocBadge'; # source -Configure the source code parsing and compilation options. +Options for input source code. ## source.assetsInclude @@ -27,11 +27,11 @@ Check out the [lib.bundle](/config/lib/bundle#set-entry) to learn how to set ent ## source.exclude -Specifies JavaScript/TypeScript files that do not need to be compiled. The usage is consistent with [Rule.exclude](https://rspack.dev/config/module#ruleexclude) in Rspack, which supports passing in strings or regular expressions to match the module path. +Specifies JavaScript/TypeScript files that do not need to be compiled. ## source.include -The `source.include` is used to specify additional JavaScript files that need to be compiled. +Specify additional JavaScript files that need to be compiled. {/* ## source.preEntry */} diff --git a/website/docs/zh/config/rsbuild/output.mdx b/website/docs/zh/config/rsbuild/output.mdx index 2580f6310..13ac3c947 100644 --- a/website/docs/zh/config/rsbuild/output.mdx +++ b/website/docs/zh/config/rsbuild/output.mdx @@ -1 +1,91 @@ +import { RsbuildDocBadge } from '@components/RsbuildDocBadge'; + # output + +与构建产物相关的选项。 + +## output.charset + +指定输出文件的 [字符编码](https://developer.mozilla.org/en-US/docs/Glossary/Character_encoding),以确保它们在不同的环境中能够正确显示。 + +## output.cleanDistPath + +是否在构建开始前清理产物目录下的所有文件(产物目录默认为 `dist`)。 + +## output.copy + +将指定的文件或目录拷贝到构建输出目录中,基于 [rspack.CopyRspackPlugin](https://rspack.dev/plugins/rspack/copy-rspack-plugin) 实现。 + +## output.cssModules + +用于自定义 CSS Modules 配置。 + +## output.dataUriLimit + +设置图片、字体、媒体等静态资源被自动内联为 base64 的体积阈值。 + +## output.distPath + +设置构建产物的输出目录,Rsbuild 会根据产物的类型输出到对应的子目录下。 + +## output.emitCss + +是否将 CSS 输出到产物中。 + +## output.externals + +在构建时,防止将代码中某些 `import` 的依赖包打包到 bundle 中,而是在运行时再去从外部获取这些依赖。 + +需要注意的是,`output.externals` 与 [resolve.alias](/config/rsbuild/resolve#resolvealias) 有所不同。请查看 [resolve.alias](/config/rsbuild/resolve#resolvealias) 文档以了解更多信息。 + +## output.filenameHash + +在生产模式构建后,是否在产物的文件名中添加 hash 值。 + +## output.filename + +设置构建产物的名称。 + +## output.inlineScripts + +用来控制是否用 `