Skip to content

andreypopp/css-stringify

 
 

Repository files navigation

css-stringify Build Status

CSS compiler using the AST provided by css-parse.

Usage

css-stringify exports a single function which dumps CSS AST:

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

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

var str = stringify(ast);

To get compressed output pass compress option:

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

To get a source map pass sourcemap 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

Note that the AST should contain position information (position option of css-parse set to true).

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.

About

CSS stringifier using the css-parse AST

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 76.6%
  • CSS 23.4%