Skip to content

Commit ad67eb7

Browse files
committed
docs(plugin-sass): improve rewriteUrls option
1 parent 306528d commit ad67eb7

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

website/docs/en/plugins/list/plugin-sass.mdx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,17 @@ pluginSass({
121121
- **Default:** `true`
122122
- **Version:** `>= 1.2.0`
123123

124-
Whether to use `resolve-url-loader` to rewrite urls.
124+
Whether to use [resolve-url-loader](https://github.com/bholloway/resolve-url-loader/tree/v5/packages/resolve-url-loader) to rewrite URLs.
125+
126+
When enabled, `resolve-url-loader` allows you to write relative URLs in your Sass files that are correctly resolved from the current Sass file's location, rather than being relative to the Sass entry file (e.g. `main.scss`).
127+
128+
If you set this option to `false`, the build performance will be improved, but Rsbuild will use the native URL resolution of Sass, which means all URLs must be relative to the Sass entry file.
129+
130+
```ts
131+
pluginSass({
132+
rewriteUrls: false,
133+
});
134+
```
125135

126136
## Practices
127137

website/docs/zh/plugins/list/plugin-sass.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,24 @@ pluginSass({
115115
});
116116
```
117117

118+
### rewriteUrls
119+
120+
- **类型:** `boolean`
121+
- **默认值:** `true`
122+
- **版本:** `>= 1.2.0`
123+
124+
是否使用 [resolve-url-loader](https://github.com/bholloway/resolve-url-loader/tree/v5/packages/resolve-url-loader) 来重写 URL。
125+
126+
当启用时,`resolve-url-loader` 允许你在 Sass 文件中写相对路径的 URL,这些 URL 会被正确地从当前 Sass 文件的位置解析,而不是相对于 Sass 入口文件(例如 `main.scss`)。
127+
128+
如果设置为 `false`,构建性能会得到提升,但 Rsbuild 会使用 Sass 的原生 URL 解析,这意味着所有 URL 必须相对于 Sass 入口文件。
129+
130+
```ts
131+
pluginSass({
132+
rewriteUrls: false,
133+
});
134+
```
135+
118136
## 实践
119137

120138
### 修改 Sass implementation

0 commit comments

Comments
 (0)