You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/en/config/lib/redirect.mdx
+43-3Lines changed: 43 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,14 +98,54 @@ When set to `false`, the file extension will remain unchanged from the original
98
98
99
99
## redirect.style
100
100
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
+
101
105
-**Type:**`boolean`
102
106
-**Default:**`true`
103
107
104
-
Whether to redirect the import path of the style file.
108
+
-**Example:**
105
109
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
+
importstylesfrom'@/foo.css'; // source code of './src/bar.ts' ↓
124
+
importstylesfrom'./foo.css'; // expected output of './dist/bar.js'
125
+
126
+
importstylesfrom'@/foo.css'; // source code of './src/utils/index.ts' ↓
127
+
importstylesfrom'../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.
0 commit comments