rework-namespace

Namespace plugin for rework

rework-namespace

Namespace plugin for rework

Usage

Pass the namespace as the first argument:

var namespace = require('rework-namespace');
 
var css = rework('.button { color: black; }')
  .use(namespace('ns'))
  .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 = rework(inputCSS)
  .use(namespace('ns', { not: [ /\.icon/, '.button-bar' ] }))
  .toString();

Only prefix specific classes or classes that match a regex.

var css = rework(inputCSS)
  .use(namespace('ns', { only: [ /\.icon/, '.icon-group' ] }))
  .toString();
var css = rework(inputCSS)
  .use(namespace('ns'))
  .toString();
var css = rework(inputCSS)
  .use(namespace('ns', {
    not: /\.icon-/,
  }))
  .toString();
var css = rework(inputCSS)
  .use(namespace('ns', {
    only: /button/,
    not: '.button'
  }))
  .toString();