Skip to content

thompsongl/postcss-class-prefix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

postcss-class-prefix Build Status


⚠️ Repo no longer actively maintained

Please look to postcss-prefixer or postcss-slds-prefix for similar functionallity in active repos.


A PostCSS plugin to prefix/namespace classes.

Avoid collisions with other libraries/stylesheets by prefixing your components with a namespace.

Example input

.Component { /* ... */ }
.Component--modifier { /* ... */ }
.Component-descendent { /* ... */ }

Example output classPrefix('pfx-')

.pfx-Component { /* ... */ }
.pfx-Component--modifier { /* ... */ }
.pfx-Component-descendent { /* ... */ }

Installation

npm install postcss-class-prefix

Usage

var fs        = require('fs');
var postcss   = require('postcss');
var classPrfx = require('postcss-class-prefix');

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

Using the ignore option

var fs        = require('fs');
var postcss   = require('postcss');
var classPrfx = require('postcss-class-prefix');

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

License

MIT

Acknowledgements

About

No Longer Maintained - A class prefixer/namespacer for postcss

Resources

License

Stars

Watchers

Forks

Packages

No packages published