Port of YUI CSS Compressor to NodeJS
npm install uglifycssUglifyCSS is a port of YUI Compressor to NodeJS for its CSS part. Its name is a reference to the awesome UglifyJS but UglifyCSS is not a CSS parser. Like YUI CSS Compressor, it applies many regexp replacements. Note that a port to JavaScript is also available in the YUI Compressor repository.
UglifyCSS passes successfully the test suite of YUI compressor CSS.
Be sure to submit valid CSS to UglifyCSS or you could get weird results.
For a command line usage:
``sh`
$ npm install uglifycss -g
For API usage:
`sh`
$ npm install uglifycss
From Github:
`sh`
$ git clone git://github.com/fmarcia/UglifyCSS.git
`sh`
$ uglifycss [options] [filename] [...] > output
Options:
* --max-line-len n adds a newline (approx.) every n characters; 0 means no newline and is the default value--expand-vars
* expands variables; by default, @variables blocks are preserved and var(x)s are not expanded--ugly-comments
* removes newlines within preserved comments; by default, newlines are preserved--cute-comments
* preserves newlines within and around preserved comments--convert-urls d
* converts relative urls using the d directory as location target--debug
* prints full error stack on error--output f
* puts the result in f file
If no file name is specified, input is read from stdin.
2 functions are provided:
* processString( content, options ) to process a given stringprocessFiles( [ filename1, ... ], options )
* to process the concatenation of given files
Options are identical to the command line:
* for --max-line-len n
* for --expand-vars
* for --ugly-comments
* for --cute-comments
* for --convert-urls d
* for --debug
Both functions return uglified css.
#### Example
`js
var uglifycss = require('uglifycss');
var uglified = uglifycss.processFiles(
[ 'file1', 'file2' ],
{ maxLineLen: 500, expandVars: true }
);
console.log(uglified);
``
UglifyCSS is MIT licensed.