Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(plugin-sass): add tip for legacy API #2493

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions website/docs/en/plugins/list/plugin-sass.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,22 @@ pluginSass({
},
});
```

```ts
pluginSass({
sassLoaderOptions: {
implementation: require.resolve('sass'),
},
});
```

Rsbuild defaults to using the latest `modern-compiler` API. If you are using an older version of Sass, please set the [api](https://github.com/webpack-contrib/sass-loader?tab=readme-ov-file#api) option of sass-loader to `legacy` to avoid exceptions caused by version mismatches.

```ts
pluginSass({
sassLoaderOptions: {
api: 'legacy',
implementation: require.resolve('sass'),
},
});
```
15 changes: 13 additions & 2 deletions website/docs/zh/plugins/list/plugin-sass.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,21 @@ pluginSass({

在某些场景下,如果你需要使用特定的 Sass 版本,而不是使用 Rsbuild 内置的 Sass embedded,可以在项目中安装需要使用的 Sass 版本,并通过 `sass-loader` 的 `implementation` 选项设置。

```js
```ts
pluginSass({
sassLoaderOptions: {
implementation: require.resolve('sass'),
},
});
```

Rsbuild 默认使用最新的 `modern-compiler` API,如果你使用的 Sass 版本较低,请将 sass-loader 的 [api](https://github.com/webpack-contrib/sass-loader?tab=readme-ov-file#api) 选项设置为 `legacy`,以避免版本不匹配导致的异常。

```ts
pluginSass({
sassLoaderOptions: {
implementation: require('sass'),
api: 'legacy',
implementation: require.resolve('sass'),
},
});
```
Loading