Port of YUI CSS Compressor to NodeJS
UglifyCSS passes successfully the test suite of YUI compressor CSS.
For a command line usage:
$ npm install uglifycss -g
For API usage:
$ npm install uglifycss
$ git clone git://github.com/fmarcia/UglifyCSS.git
$ uglifycss [options] [filename] [...] > output
--max-line-len nadds a newline (approx.) every
0means no newline and is the default value
--expand-varsexpands variables; by default,
@variablesblocks are preserved and
var(x)s are not expanded
--ugly-commentsremoves newlines within preserved comments; by default, newlines are preserved
--cute-commentspreserves newlines within and around preserved comments
If no file name is specified, input is read from stdin.
2 functions are provided:
processString( content, options )to process a given string
processFiles( [ filename1, ... ], options )to process the concatenation of given files
Options are identical to the command line:
Both functions return uglified css.
var uglifycss = require'uglifycss';var uglified = uglifycssprocessFiles'file1' 'file2'maxLineLen: 500 expandVars: true;console.loguglified;
See also test.js.
UglifyCSS is MIT licensed.