Skip to content
A class namespacer for postcss
JavaScript
Branch: master
Clone or download
Pull request Compare This branch is 3 commits ahead, 1 commit behind thompsongl:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.gitignore
CHANGELOG.md
LICENSE
README.md
index.js
package.json

README.md

postcss-parent-scope

A PostCSS plugin to scope CSS with a parent class.

wrap Example input

.Component { /* ... */ }
.Component--modifier { /* ... */ }
.Component-descendent { /* ... */ }
.Component1, .Component2 { /* ... */ }

Example output parentScope('parent-wrapper')

.parent-wrapper .Component { /* ... */ }
.parent-wrapper .Component--modifier { /* ... */ }
.parent-wrapper .Component-descendent { /* ... */ }
.parent-wrapper .Component1, .parent-wrapper .Component2 { /* ... */ }

Installation

npm install postcss-parent-scope

Usage

var fs        = require('fs');
var postcss   = require('postcss');
var parentScope = require('postcss-parent-scope');

var css = fs.readFileSync('css/my-file.css', 'utf8').toString();
var out = postcss()
          .use(parentScope('parent-class'))
          .process(css);

Using the ignore option

var fs        = require('fs');
var postcss   = require('postcss');
var parentScope = require('postcss-parent-scope');

var css = fs.readFileSync('css/my-file.css', 'utf8').toString();
var out = postcss()
          .use(parentScope('parent-class', { ignore: [/ng-/, 'some-class-to-ignore']}))
          .process(css);

License

MIT

You can’t perform that action at this time.