fmarcia / uglifycss

Port of YUI CSS Compressor from Java to NodeJS
MIT License
284 stars 37 forks source link
css javascript minify nodejs stylesheet uglify

UglifyCSS 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.

Installation

For a command line usage:

$ npm install uglifycss -g

For API usage:

$ npm install uglifycss

From Github:

$ git clone git://github.com/fmarcia/UglifyCSS.git

Command line

$ uglifycss [options] [filename] [...] > output

Options:

If no file name is specified, input is read from stdin.

API

2 functions are provided:

Options are identical to the command line:

Both functions return uglified css.

Example

var uglifycss = require('uglifycss');

var uglified = uglifycss.processFiles(
    [ 'file1', 'file2' ],
    { maxLineLen: 500, expandVars: true }
);

console.log(uglified);

License

UglifyCSS is MIT licensed.