component-minify

Minify css/js output with uglify-js and clean-css

npm install component-minify
4 downloads in the last day
18 downloads in the last week
87 downloads in the last month

Component Minify

Plugin for component-buider, to minify js/css output with uglify-js and clean-css.

Usage

It useful to prepare assets for production from command line,

$ component build --use component-minify

Or manually with builder.js:

var Builder = require('component-builder');
var minify  = require('component-minify');
var fs      = require('fs');

// https://github.com/GoalSmashers/clean-css#how-to-use-clean-css-programmatically
// default {}
minify.cleanCSS = { removeEmpty: true };

// https://github.com/mishoo/uglifyjs#api
// default {}
minify.uglifyJS = { mangle: false };

var builder = new Builder(__dirname)
  .use(minify);

builder.build(function(err, res){
  if (err) throw err;
  if (res.js) fs.writeFileSync('build/build.js', res.require + res.js);
  if (res.css) fs.writeFileSync('build/build.css', res.css);
});
npm loves you