Skip to content

Commit de43409

Browse files
committed
docs: translate
1 parent 7fc88ad commit de43409

File tree

2 files changed

+66
-15
lines changed

2 files changed

+66
-15
lines changed

website/docs/en/config/lib/redirect.mdx

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,54 @@ When set to `false`, the file extension will remain unchanged from the original
9898

9999
## redirect.style
100100

101+
### redirect.style.path
102+
103+
Whether to automatically redirect the import path when importing style files, the rules are the same as [redirect.js.path](/config/lib/redirect#redirectjspath).
104+
101105
- **Type:** `boolean`
102106
- **Default:** `true`
103107

104-
Whether to redirect the import path of the style file.
108+
- **Example:**
105109

106-
For example, when importing a `.less` file, it will be rewritten to a `.css` file:
110+
When importing normal style files:
111+
112+
```ts
113+
import '@/foo.css'; // source code of './src/bar.ts' ↓
114+
import './foo.css'; // expected output of './dist/bar.js'
115+
116+
import '@/foo.css'; // source code of './src/utils/index.ts' ↓
117+
import '../foo.css'; // expected output of './dist/utils/index.js'
118+
```
119+
120+
When importing [CSS Modules](/zh/config/rsbuild/output#outputcssmodules) files:
121+
122+
```ts
123+
import styles from '@/foo.css'; // source code of './src/bar.ts' ↓
124+
import styles from './foo.css'; // expected output of './dist/bar.js'
125+
126+
import styles from '@/foo.css'; // source code of './src/utils/index.ts' ↓
127+
import styles from '../foo.css'; // expected output of './dist/utils/index.js'
128+
```
129+
130+
### redirect.style.extension
131+
132+
Whether to redirect style file extensions.
133+
134+
- **Type:** `boolean`
135+
- **Default:** `true`
136+
137+
When set to `true`, When importing a normal style file, the path will be rewritten to the `.css` file. When importing [CSS Modules](/zh/config/rsbuild/output#outputcssmodules), the path will be rewritten to the corresponding JavaScript output file.
138+
139+
When set to `false`, The file extension will remain unchanged from the original import path.
140+
141+
- **Example:**
142+
143+
When importing from a `.less` file:
107144

108145
```ts
109146
import './index.less'; // source code ↓
110-
import './index.css'; // output file
147+
import './index.css'; // expected output
148+
149+
import styles from './index.module.less'; // source code ↓
150+
import styles from './index.module.mjs'; // expected output
111151
```

website/docs/zh/config/lib/redirect.mdx

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,26 @@ const defaultRedirect = {
108108
- **类型:** `boolean`
109109
- **默认值:** `true`
110110

111-
- 示例:
111+
- **示例:**
112112

113-
该配置常用于解析别名,当配置 `@` 指向项目 `src` 目录时
113+
导入普通样式文件时
114114

115115
```ts
116-
// src/index.ts
117-
import '@/css/index.css'; // src/css/index.css
118-
// dist/index.js
119-
import './css/index.css'; // dist/css/index.css
116+
import '@/foo.css'; // './src/bar.ts' 的源码 ↓
117+
import './foo.css'; // './dist/bar.js' 预期生成的代码
118+
119+
import '@/foo.css'; // './src/utils/index.ts' 的源码 ↓
120+
import '../foo.css'; // './dist/utils/index.js' 预期生成的代码
121+
```
122+
123+
导入 [CSS Modules](/zh/config/rsbuild/output#outputcssmodules) 时:
124+
125+
```ts
126+
import styles from '@/foo.css'; // './src/bar.ts' 的源码 ↓
127+
import styles from './foo.css'; // './dist/bar.js' 预期生成的代码
128+
129+
import styles from '@/foo.css'; // './src/utils/index.ts' 的源码 ↓
130+
import styles from '../foo.css'; // './dist/utils/index.js' 预期生成的代码
120131
```
121132

122133
### redirect.style.extension
@@ -126,18 +137,18 @@ import './css/index.css'; // dist/css/index.css
126137
- **类型:** `boolean`
127138
- **默认值:** `true`
128139

129-
当设置为 `true` 时,导入样式文件时,路径将被重写为 `.css` 文件,当导入 [CSS Modules](/zh/config/rsbuild/output#outputcssmodules) 时,路径将被重写为到对应的 JavaScript 输出文件。
140+
当设置为 `true` 时,导入普通样式文件时,路径将被重写为 `.css` 文件,导入 [CSS Modules](/zh/config/rsbuild/output#outputcssmodules) 时,路径将被重写为到对应的 JavaScript 输出文件。
130141

131142
当设置为 `false` 时,文件扩展名将保持原始导入路径中的不变。
132143

133-
- 示例:
144+
- **示例:**
134145

135146
默认情况下,当从 `.less` 文件导入时:
136147

137148
```ts
138-
import './index.less'; // source code
139-
import './index.css'; // output file
149+
import './index.less'; // 源码
150+
import './index.css'; // 预期生成的代码
140151

141-
import styles from './index.module.less'; // source code
142-
import styles from './index.module.mjs'; // output file
152+
import styles from './index.module.less'; // 源码
153+
import styles from './index.module.mjs'; // 预期生成的代码
143154
```

0 commit comments

Comments
 (0)