Use Sass as the CSS preprocessor, implemented based on sass-loader.
You can install the plugin using the following command:
You can register the plugin in the rsbuild.config.ts
file:
After registering the plugin, you can import *.scss
, *.sass
, *.module.scss
or *.module.sass
files into the code without adding other configs.
If you need to customize the compilation behavior of Sass, you can use the following configs.
Modify the config of sass-loader.
Object | Function
If sassLoaderOptions
is an object, it is merged with the default config through Object.assign
. It should be noted that sassOptions
is merged through deepMerge in a deep way.
If sassLoaderOptions
is a function, the default config is passed as the first parameter, which can be directly modified or returned as the final result.
In some scenarios, if you need to use a specific version of Sass instead of the built-in Sass embedded in Rsbuild, you can install the desired Sass version in your project and set it up using the implementation
option of the sass-loader
.