Namespace plugin for PostCSS - based on Kristofer Joseph's rework-namespace plugin.
Pass the namespace as the first argument:
var namespace = require('postcss-add-namespace');
var css = postcss([namespace('ns')])
.process('.button { color: black; }')
.then(results => {results.toString()});
Results:
.ns-button { color: black; }
Pass an options object as the second argument.
Don't prefix specific classes or classes that match a regex.
var css = postcss([namespace('ns', { not: [ /\.icon/, '.button-bar' ] })])
.process(inputCSS)
.then(results => {results.toString()});
Only prefix specific classes or classes that match a regex.
var css = postcss([namespace('ns', { only: [ /\.icon/, '.icon-group' ] })])
.process(inputCSS)
.then(results => {results.toString()});
var css = postcss([namespace('ns')])
.process(inputCSS)
.then(results => {results.toString()});
var css = postcss([namespace('ns', { not: /\.icon-/ })])
.process(inputCSS)
.then(results => {results.toString()});
var css = postcss([namespace('ns', {
only: /button/,
not: '.button'
})])
.process(inputCSS)
.then(results => {results.toString()});