Skip to content

Commit 01db68b

Browse files
authored
docs: add configure rsbuild / rspack (#532)
1 parent 5840026 commit 01db68b

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

website/docs/en/guide/basic/configure-rstest.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,23 @@ You can also abbreviate the `--config` option to `-c`:
4141
rstest -c scripts/rstest.config.mjs
4242
```
4343

44+
## Configure Rsbuild
45+
46+
Rstest's build configuration inherits from Rsbuild. Therefore, in Rstest, you can use most of the Rsbuild configurations, such as:
47+
48+
- Using Rsbuild plugins through [plugins](/config/#plugins);
49+
- Configuring module resolution behavior through [resolve](/config/build/resolve);
50+
- Configuring Rspack through [tools.rspack](/config/build/tools#toolsrspack);
51+
- Configuring builtin:swc-loader through [tools.swc](/config/build/tools#toolsswc).
52+
53+
More configurations can be referred to [Build Configurations](/config/#build-configurations).
54+
55+
## Configure Rspack
56+
57+
Rstest uses Rspack for building, so you can directly use Rspack's configuration options to configure Rstest's build behavior.
58+
59+
More details can be referred to [Configure Rspack](https://rsbuild.rs/guide/configuration/rspack).
60+
4461
## Detect Rstest environment
4562

4663
You can use `process.env.RSTEST` to detect whether it is an Rstest test environment to apply different configurations/codes in your tests.

website/docs/zh/guide/basic/configure-rstest.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,23 @@ Rstest CLI 通过 `--config` 选项来指定配置文件,可以设置为相对
4141
rstest -c scripts/rstest.config.mjs
4242
```
4343

44+
## 配置 Rsbuild
45+
46+
Rstest 的构建配置继承自 Rsbuild。因此,在 Rstest 中,你可以使用绝大部分的 Rsbuild 配置。如:
47+
48+
- 通过 [plugins](/config/#plugins) 使用 Rsbuild 插件;
49+
- 通过 [resolve](/config/build/resolve) 对模块解析行为进行配置;
50+
- 通过 [tools.rspack](/config/build/tools#toolsrspack) 配置 Rspack;
51+
- 通过 [tools.swc](/config/build/tools#toolsswc) 对 builtin:swc-loader 进行配置。
52+
53+
更多配置可参考 [构建配置](/config/#build-configurations)
54+
55+
## 配置 Rspack
56+
57+
Rstest 底层使用 Rspack 进行构建,因此你可以直接使用 Rspack 的配置项来配置 Rstest 的构建行为。
58+
59+
详情可参考 [配置 Rspack](https://rsbuild.rs/zh/guide/configuration/rspack)
60+
4461
## 检测 Rstest 环境
4562

4663
你可以使用 `process.env.RSTEST` 来检测是否是 Rstest 测试环境以应用不同的配置 / 代码在你的测试中。

website/theme/components/ConfigOverview.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Link } from '@rspress/core/theme';
22
import styles from './ConfigOverview.module.scss';
3+
import { useI18nUrl } from './utils';
34

45
export interface GroupItem {
56
text: string;
@@ -59,14 +60,15 @@ const OVERVIEW_GROUPS: Group[] = [
5960
];
6061

6162
export default function Overview() {
63+
const tUrl = useI18nUrl();
6264
const Nodes = OVERVIEW_GROUPS.map((group) => (
6365
<div key={group.name} className={styles.overviewGroups}>
6466
<div className={styles.group}>
6567
<h2>{group.name}</h2>
6668
<ul>
6769
{group.items?.map((item) => (
6870
<li key={item}>
69-
<Link href={`/config/test/${item}`}>{item}</Link>
71+
<Link href={tUrl(`/config/test/${item}`)}>{item}</Link>
7072
</li>
7173
))}
7274
</ul>
@@ -119,17 +121,20 @@ const BUILD_OVERVIEW_GROUPS: Group[] = [
119121
];
120122

121123
export function BuildOverview() {
124+
const tUrl = useI18nUrl();
122125
const Nodes = BUILD_OVERVIEW_GROUPS.map((group) => (
123126
<div key={group.name} className={styles.overviewGroups}>
124127
<div className={styles.group}>
125128
<h2>
126-
<Link href={`/config/build/${group.name}`}> {group.name}</Link>
129+
<Link href={tUrl(`/config/build/${group.name}`)}> {group.name}</Link>
127130
</h2>
128131
<ul>
129132
{group.items?.map((item) => (
130133
<li key={item}>
131134
<Link
132-
href={`/config/build/${group.name}#${item.replace('.', '')}`}
135+
href={tUrl(
136+
`/config/build/${group.name}#${item.replace('.', '')}`,
137+
)}
133138
>
134139
{item}
135140
</Link>

0 commit comments

Comments
 (0)