Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
split css files into arrays that you can use to set prefixes
JavaScript
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
example
test
.travis.yml
LICENSE
index.js
package.json
readme.markdown

readme.markdown

split-css

Split css files into arrays that you can use to set prefixes.

build status

exposition

By splitting a css file in just the right places:

var css = [".","title.","today {\n    font-weight: bold;\n}\n\n.","body {\n    font-size: 14px;\n}"]

it's possible to set css prefixes with only a single .join():

var output = css.join('PREFIX-')
console.log(output);

.PREFIX-title.PREFIX-today {
    font-weight: bold;
}

.PREFIX-body {
    font-size: 14px;
}

Having css files split into arrays like this is useful for browser experiments where you need to set prefixes for entire css files dynamically but don't want to bundle an entire css parser browser-side.

example

var split = require('../');
var fs = require('fs');

var src = fs.readFileSync(__dirname + '/style.css', 'utf8');
var chunks = split(src);
console.dir(chunks);

[ '.',
  'body {\n    color: green;\n    padding: 15px;\n}\n\ndiv#',
  'robots .',
  'beep.',
  'boop {\n    text-align: center;\n}\n\n#',
  'a.',
  'b > .',
  'bling.',
  'blong {\n    margin: auto;\n}\n\na.',
  'clickable[href="/x.y.z"]:link, a.',
  'clickable[href="/x.y.z"]:visited {\n    color: cyan;\n}\n' ]

methods

var split = require('split-css')

split(src)

Return an array from the source string src split at the leading character in each id or class definition in the selector rules.

install

With npm do:

npm install split-css

license

MIT

Something went wrong with that request. Please try again.