minify-js
v0.0.4
Published
Minification javascript files for ECMA 5 and ECMA 6. May be etc.
Downloads
628
Maintainers
Readme
minify-js
library for minification javascript files
Installation
npm install minify-js --save
example
var minify = require('./index');
var async = require('async');
var ut = require('util');
async.series([
(done) => {
console.log('Test compres one file');
minify.file({
file : './for-example/src/experimental.js',
dist : './for-example/experimental.min.js'
}, (e, compress) => {
if (e) {
console.log('ERROR ', e);
return done();
}
compress.run((e) => {
e ? console.log('Process fail', e) : console.log('Process sucess');
done();
});
});
},
(done) => {
console.log('Test compres two files');
minify.files([
{
file : './for-example/src/experimental.js',
dist : './for-example/two/experimental.min.js'
},
{
file : './for-example/src/experimental1.js',
dist : './for-example/two/experimental2.min.js'
}
], (e, compress) => {
if (e) {
console.log('ERROR ', e);
return done();
}
compress.run((e) => {
e ? console.log('Process fail', e) : console.log('Process sucess');
done();
});
});
},
(done) => {
console.log('Test compres all files in dirs');
minify.dir({
dir : 'for-example/src',
target : 'for-example/target',
add : '.min'
}, (e, compress) => {
if (e) {
console.log('ERROR ', e);
return done();
}
compress.run((e) => {
e ? console.log('Process fail', e) : console.log('Process sucess');
done();
});
});
},
(done) => {
console.log('Test compres lib file');
minify.file({
file : './lib/minify-js.js',
dist : './lib/prod/minify-js.js'
}, (e, compress) => {
if (e) {
console.log('ERROR ', e);
return done();
}
compress.run((e) => {
e ? console.log('Process fail', e) : console.log('Process sucess');
done();
});
});
}
], function (e) {
console.log('The end :)');
});
minify-js~Frame
It is a frame for other classes
Kind: inner class of minify-js
frame.err(mess, data) ⇒ Object
Return error object and set flag for stop process
Kind: instance method of Frame
| Param | | --- | | mess | | data |
frame.warn(mess, that)
Get text for message
Kind: instance method of Frame
| Param | Type | | --- | --- | | mess | String | | that | Class |
minify-js~MinifyFile
Minification one javascript file
Kind: inner class of minify-js
minifyFile.run(cb)
Start process
Kind: instance method of MinifyFile
| Param | Type | | --- | --- | | cb | function |
minifyFile.fileRead(cb)
Get file contents
Kind: instance method of MinifyFile
| Param | Type | | --- | --- | | cb | function |
minifyFile.save(cb)
Save result
Kind: instance method of MinifyFile
| Param | Type | | --- | --- | | cb | function |
minifyFile.compess(cb)
Compress file contents
Kind: instance method of MinifyFile
| Param | Type | | --- | --- | | cb | function |
minifyFile.validOptions(opt, cb) ⇒ *
Check options
Kind: instance method of MinifyFile
| Param | Type | | --- | --- | | opt | Object | | cb | function |
minify-js~MinifyFiles
Minification not one javascript file
Kind: inner class of minify-js
minifyFiles.validOptions(opt, cb) ⇒ *
Check options
Kind: instance method of MinifyFiles
| Param | Type | | --- | --- | | opt | Array | | cb | function |
minifyFiles.run(cb)
Start process
Kind: instance method of MinifyFiles
| Param | Type | | --- | --- | | cb | function |
minify-js~MinifyFilesDir
Minification all javascript file in folder
Kind: inner class of minify-js
minifyFilesDir.validOptions(opt, cb) ⇒ *
Check options Format options {dir : 'source folder', targer : 'destination folder' , add : 'add to name' }
Kind: instance method of MinifyFilesDir
| Param | Type | | --- | --- | | opt | Object | | cb | function |
minifyFilesDir.run(cb)
Start process
Kind: instance method of MinifyFilesDir
| Param | Type | | --- | --- | | cb | function |
version
0.0.3 - Attach unit test. 0.0.4 - More solution for compress.