Rework plugin for modular css
Rework plugin for modular css.
rework-modules allows you to export and require other css modules and easily share variables and extensions.
See the tests for some examples.
$ npm install rework-modules
rework-modules expects an object as an argument that contains functions to load content. It also needs an
index to be told where to start loading. For example, let's say we have the following directory structure:
$ tree.├── my-app│ ├── index.styl│ └── other-styles.styl├── my-theme│ ├── index.styl
We would need to pass an object like the following:
var rework = require'rework-modules';var read = require'fs'readFileSync;returnreturn readfile 'utf8';var modules ='index': 'my-app/index''my-app': 'my-app/index''my-app/index': load'my-app/index.styl''my-app/other-styles': load'my-app/other-styles.styl''my-theme': 'my-theme/index''my-theme/index': load'my-theme/index.styl';var out = reworkmodules;
You can also specify the main style as a second parameter:
var out = reworkmodules 'my-app/other-styles';
The value returned is the
Rework object and can easily be extended like you're used to:
var out = reworkmodulesusemyReworkPlugintoString;
css-whitespace plugin is already included.
Once a module is required we can start using the exported variables from it:
You can also use exported placeholders if you've included the inherit plugin:
By default the content of a required module is not included. To include it use
$ npm test