close
logologo
Guide
Config
Plugin
API
Community
Version
Changelog
Rsbuild 0.x Doc
English
简体中文
Guide
Config
Plugin
API
Community
Changelog
Rsbuild 0.x Doc
English
简体中文
logologo

Plugins

Plugin list
React plugin
SVGR plugin
Vue plugin
Preact plugin
Svelte plugin
Solid plugin
Babel plugin
Sass plugin
Less plugin
Stylus plugin

Development

Plugin development
Plugin API
Plugin hooks
📝 Edit this page on GitHub
Previous PageLess plugin
Next PagePlugin development

#Stylus plugin

Source

Stylus is an Expressive, dynamic and robust CSS preprocessor. With Stylus plugins, you can use Stylus as the CSS preprocessor.

#Quick start

#Install plugin

You can install the plugin using the following command:

npm
yarn
pnpm
bun
npm add @rsbuild/plugin-stylus -D

#Register plugin

You can register the plugin in the rsbuild.config.ts file:

rsbuild.config.ts
import { pluginStylus } from '@rsbuild/plugin-stylus';

export default {
  plugins: [pluginStylus()],
};

#Example

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-serif
  • title.module.styl:
.title
   font-size: 14px;
  • index.js:
import './normalize.styl';
import style from './title.module.styl';

console.log(style.title);

#Options

To customize the compilation behavior of Stylus, use the following options.

#stylusOptions

-Type:

type StylusOptions = {
  use?: string[];
  define?: [string, any, boolean?][];
  include?: string[];
  includeCSS?: boolean;
  import?: string[];
  resolveURL?: boolean;
  lineNumbers?: boolean;
  hoistAtrules?: boolean;
};
  • Default: undefined

Options passed to Stylus, please refer to the Stylus documentation for specific usage.

pluginStylus({
  stylusOptions: {
    lineNumbers: false,
  },
});

#sourceMap

  • Type: boolean
  • Default: the same as output.sourceMap.css

Whether to generate source map.

pluginStylus({
  sourceMap: false,
});