Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
insert a prefix into every class and identifier in a css document
JavaScript
branch: master

README.markdown

css-prefix

Insert a prefix into css documents.

build status

example

var fs = require('fs');
var src = fs.readFileSync(__dirname + '/beep.css', 'utf8');

var insertPrefix = require('css-prefix');
var dst = insertPrefix('RAWR-', src);
console.log(dst);

beep.css:

#beep div.boop.killer-robots {
    color: red;
}

#beep .friendly-robots {
    color: green;
}

output:

#RAWR-beep div.RAWR-boop.RAWR-killer-robots {
    color: red;
}

#RAWR-beep .RAWR-friendly-robots {
    color: green;
}

methods

var insertPrefix = require('css-prefix')

insertPrefix(opts, src)

Insert the string opts.prefix before every class and id in the css source string src, returning the transformed source.

If opts.elementClass is given, add this class to all element identifiers. This is useful so that your h1 { color: green; } declarations don't leak into the environment.

If opts.parentClass is given, add an ancestor class to every rule.

If opts is a string, treat opts as opts.prefix.

install

With npm do:

npm install css-prefix

license

MIT

Something went wrong with that request. Please try again.