Stylus is an expressive, dynamic, and robust CSS preprocessor. With this plugin, you can use Stylus as the CSS preprocessor in Rsbuild.
Install:
npm add @rsbuild/plugin-stylus -DAdd plugin to your rsbuild.config.ts:
// rsbuild.config.ts
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 without adding other configs.
// normalize.styl
body
color #000
font 14px Arial, sans-serif// title.module.styl
.title
font-size 14px// index.js
import './normalize.styl';
import style from './title.module.styl';
console.log(style.title);- Type:
type StylusOptions = {
use?: string[];
define?: [string, unknown, boolean?][];
include?: string[];
includeCSS?: boolean;
import?: string[];
resolveURL?: boolean;
lineNumbers?: boolean;
hoistAtrules?: boolean;
};- Default:
undefined
These options are passed to Stylus. For details, see the Stylus documentation.
pluginStylus({
stylusOptions: {
lineNumbers: false,
},
});- Type:
boolean - Default: the same as Rsbuild's
output.sourceMap.cssconfig
Whether to generate source maps.
pluginStylus({
sourceMap: false,
});MIT.