Skip to content

Commit

Permalink
docs(plugin-sass): improve rewriteUrls option (#4401)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Jan 21, 2025
1 parent 306528d commit e1f5488
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
12 changes: 11 additions & 1 deletion website/docs/en/plugins/list/plugin-sass.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,17 @@ pluginSass({
- **Default:** `true`
- **Version:** `>= 1.2.0`

Whether to use `resolve-url-loader` to rewrite urls.
Whether to use [resolve-url-loader](https://github.com/bholloway/resolve-url-loader/tree/v5/packages/resolve-url-loader) to rewrite URLs.

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`).

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.

```ts
pluginSass({
rewriteUrls: false,
});
```

## Practices

Expand Down
18 changes: 18 additions & 0 deletions website/docs/zh/plugins/list/plugin-sass.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,24 @@ pluginSass({
});
```

### rewriteUrls

- **类型:** `boolean`
- **默认值:** `true`
- **版本:** `>= 1.2.0`

是否使用 [resolve-url-loader](https://github.com/bholloway/resolve-url-loader/tree/v5/packages/resolve-url-loader) 来重写 URL。

当启用时,`resolve-url-loader` 允许你在 Sass 文件中写相对路径的 URL,这些 URL 会被正确地从当前 Sass 文件的位置解析,而不是相对于 Sass 入口文件(例如 `main.scss`)。

如果设置为 `false`,构建性能会得到提升,但 Rsbuild 会使用 Sass 的原生 URL 解析,这意味着所有 URL 必须相对于 Sass 入口文件。

```ts
pluginSass({
rewriteUrls: false,
});
```

## 实践

### 修改 Sass implementation
Expand Down

0 comments on commit e1f5488

Please sign in to comment.