PostCSS plugin that adds a user input scope to each selector. for a command line interface, see scopify-cli.
Example input
.foo, .boo h1 {
/* declarations */
}
& {
/* declarations */
}
Example output
scopify('#scope')
or scopify({scope: '#scope'})
#scope .foo, #scope .boo h1 {
/* declarations */
}
#scope {
/* declarations */
}
npm install postcss-scopify
var fs = require('fs');
var postcss = require('postcss');
var scopify = require('postcss-scopify');
var css = fs.readFileSync('css/my-file.css', 'utf8').toString();
var out = postcss()
.use(scopify('#scope'))
.process(css)
.css;
You can use PostCSS with your build tool. Note there are plugins for Grunt, Gulp, webpack, Broccoli, Brunch and ENB. See PostCSS docs for examples for your environment.
- update all deps to latest versions
- update plugin syntax for postCss v8+
- allow pass scope as object (because postcss+webpack)
closes #10
fixes #7
closes #3
fixes #4