rollup-plugin-stylus-css-modules

A Rollup.js plugin to compile Stylus and inject CSS Modules

MIT 14 个版本
安装
npm install rollup-plugin-stylus-css-modules
yarn add rollup-plugin-stylus-css-modules
pnpm add rollup-plugin-stylus-css-modules
bun add rollup-plugin-stylus-css-modules
README

rollup-plugin-stylus-css-modules

Build Status

A Rollup.js plugin to compile Stylus and inject CSS Modules.

Installation

$ npm install --save-dev rollup-plugin-stylus-css-modules

Usage

Add the following code to your project's rollup.config.js:

import stylusCssModules from 'rollup-plugin-stylus-css-modules';

export default {
  entry: 'index.js',
  plugins: [
    stylusCssModules({
      output: 'styles.css'
    })
  ]
};

in Stylus

.container
  height 100%

in JS

import styles from './styles.styl';
const container = `<div class="${styles.container}">...</div>`;

Options

  • include, exclude: A minimatch pattern, or an array of minimatch patterns of including ID, or excluding ID (optional).
  • output: Output destination (optional).
    • If you specify as string, it will be the path to write the generated CSS.
    • If you specify as function, call it passing the generated CSS as an argument.
    • If you specify the false, CSS will not be output.
    • If this option is not specified, the generated CSS will still be imported (See Use with other CSS plugins).
  • sourceMap: If true is specified, source map to be embedded in the output CSS (default is true).
  • fn: A function invoked with the Stylus renderer (it will be passed to use() function of the Stylus).

Use with external tools

Combination with external tools, such as PostCSS works perfectly.

stylusCssModules({
  sourceMap: true,
  output: (css) => {
    return postcss([
      // postcss' plugins...
    ]).process(css, {
      map: true
    }).then((result) => {
      fs.writeFileSync('styles.css', result.css);
    });
  }
});

Use with other CSS plugins

You can also use the Rollup.js plugin, such as rollup-plugin-postcss, rollup-plugin-css-only, etc.

export default {
  entry: 'index.js',
  plugins: [
    stylusCssModules(),
    postcss()
  ]
};

License

MIT

版本列表
1.5.0 2017-07-20
1.4.1 2017-07-20
1.4.0 2017-05-24
1.3.0 2017-05-17
1.2.3 2016-12-22
1.2.2 2016-10-05
1.2.1 2016-07-14
1.2.0 2016-06-24
1.1.1 2016-06-22
1.1.0 2016-06-20
1.0.5 2016-06-14
1.0.3 2016-05-10
1.0.2 2016-02-04
1.0.1 2016-02-03