diff --git a/website/docs/en/plugins/list/plugin-sass.mdx b/website/docs/en/plugins/list/plugin-sass.mdx index c9b835ff76..bf509ba232 100644 --- a/website/docs/en/plugins/list/plugin-sass.mdx +++ b/website/docs/en/plugins/list/plugin-sass.mdx @@ -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 diff --git a/website/docs/zh/plugins/list/plugin-sass.mdx b/website/docs/zh/plugins/list/plugin-sass.mdx index 0c7eaf3fa0..56425c109b 100644 --- a/website/docs/zh/plugins/list/plugin-sass.mdx +++ b/website/docs/zh/plugins/list/plugin-sass.mdx @@ -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