CSSO (CSS Optimizer) is a CSS minimizer unlike others. In addition to usual minification techniques it can perform structural optimization of CSS files, resulting in smaller file size compared to other minifiers.
npm install -g csso
csso [input] [output] [options]
Options:
--debug Output intermediate state of CSS during compression
-h, --help Output usage information
-i, --input <filename> Input file
-o, --output <filename> Output file (result outputs to stdout if not set)
--restructure-off Turns structure minimization off
-v, --version Output the version
Some examples:
> csso in.css out.css
> csso in.css
...output result in stdout...
> echo ".test { color: #ff0000; }" | csso
.test{color:red}
> cat source1.css source2.css | csso | gzip -9 -c > production.css.gz
var csso = require('csso');
var compressed = csso.minify('.test { color: #ff0000; }');
console.log(compressed);
// .test{color:red}
// you may do it step by step
var ast = csso.parse('.test { color: #ff0000; }');
ast = csso.compress(ast);
var compressed = csso.translate(ast, true);
console.log(compressed);
// .test{color:red}
// There are two options you can pass
var compressedWithOptions = csso.minify('.test { color: #ff0000; }', {
restructuring: false, // don't combine same selectors
debug: true // show additional debug information
})
May be outdated