Home

Awesome

rework-namespace BuildStatus

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; }

Options

Pass an options object as the second argument.

options.not

Don't prefix specific classes or classes that match a regex.

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

options.only

Only prefix specific classes or classes that match a regex.

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

Examples

Prefix every class

var css = rework(inputCSS)
  .use(namespace('ns'))
  .toString();

Prefix every class except icon classes

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

Prefix all classes with "button" in them except .button itself

var css = rework(inputCSS)
  .use(namespace('ns', {
    only: /button/,
    not: '.button'
  }))
  .toString();