Stylus is an Expressive, dynamic and robust CSS preprocessor. With Stylus plugins, you can use Stylus as the CSS preprocessor.
You can install the plugin using the following command:
npm add @rsbuild/plugin-stylus -DYou can register the plugin in the rsbuild.config.ts file:
import { pluginStylus } from '@rsbuild/plugin-stylus';
export default {
plugins: [pluginStylus()],
};After registering the plugin, you can import *.styl, *.stylus, *.module.styl or *.module.stylus files into the code without adding other configs.
normalize.styl:the body
color#000
font 14px Arial, sans-seriftitle.module.styl:.title
font-size: 14px;index.js:import './normalize.styl';
import style from './title.module.styl';
console.log(style.title);To customize the compilation behavior of Stylus, use the following options.
-Type:
type StylusOptions = {
use?: string[];
define?: [string, any, boolean?][];
include?: string[];
includeCSS?: boolean;
import?: string[];
resolveURL?: boolean;
lineNumbers?: boolean;
hoistAtrules?: boolean;
};undefinedOptions passed to Stylus, please refer to the Stylus documentation for specific usage.
pluginStylus({
stylusOptions: {
lineNumbers: false,
},
});booleanWhether to generate source map.
pluginStylus({
sourceMap: false,
});