css-stringify

CSS compiler

npm install css-stringify
9 348 downloads in the last day
53 285 downloads in the last week
226 082 downloads in the last month

css-stringify Build Status

CSS compiler using the AST provided by css-parse.

API

stringify(object, [options])

Accepts an AST object from css-parse and returns a CSS string.

var stringify = require('css-stringify');
var parse = require('css-parse');

var ast = parse('body { font-size: 12px; }');
var css = stringify(ast);

Optionally you may compress the output:

var css = stringify(ast, { compress: true });

Or return a sourcemap along with the CSS output, which requires the use of the css-parse position option.

var ast = parse('body { font-size: 12px; }', { position: true });
var result = stringify(ast, { sourcemap: true });

result.code // string with CSS
result.map // source map

Performance

Formats 15,000 lines of CSS (2mb) in 23ms on my macbook air.

License

(The MIT License)

Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

npm loves you