Minify - a minifier of js, css, html and img files, used in Cloud Commander project.
To use minify
as middleware try Mollify.
You can install minify via npm:
npm i minify -g
Command line syntax:
minify <input-file1> <input-file2> <input-fileN> > output
stdout | minify -<flag>
For example:
minify client.js util.js > all.js
minify screen.css reset.css > all.css
cat client.js | minify -js
cat *.css | minify -css
The Minify module contains an api for interacting with other js files.
minify = require('minify');
After minification, a file will be saved in the temporary directory.
minify - function to minificate js, html and css-files.
- file - path to file.
- options(optional) - object contains options.
- callback
Possible options:
- name
- stream
Examples:
var minify = require('minify');
minify('client.js', 'name', function(error, name) {
console.log(error || name);
});
minify('client.js', 'stream', function(error, stream) {
var streamWrite = fs.createWriteStream('client.min.js');
if (error)
console.error(error.message);
else
stream.pipe(streamWrite);
});
if post processing is needed:
minify('client.js', function(error, data) {
});
Gets data on input. Parameters:
- Object with data and extensions (
.js
,.css
,img
) - Callback
Example:
minify({
ext: '.js',
data: 'function hello() { if (2 > 3) console.log(\'for real\')}'
}, function(error, data) {
console.log(error, data);
});
To use as express middleware [mollify](https://github.com/coderaiser/node-mollify Mollify) could be used.
MIT