Last active
August 29, 2015 14:15
-
-
Save thexodus/889e5ad8e2eb3089e910 to your computer and use it in GitHub Desktop.
file minifier and zipper with node (css and javascript)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs') | |
var zlib = require('zlib') | |
var gzip = zlib.createGzip(); | |
var compressor = require(process.env['HOME'] + '/node_modules/node-minify'); | |
new compressor.minify({ | |
type: 'gcc', | |
fileIn: 'js/main.js', | |
fileOut: 'js/main.min.js', | |
callback: function(err, min){ | |
console.log(err); | |
if(err == null){ | |
console.log("Created minified file.") | |
console.log("Initializing creation of zip(gz) file...."); | |
var inp = fs.createReadStream('js/main.min.js'); | |
var out = fs.createWriteStream('js/main.js.gz'); | |
inp.pipe(gzip).pipe(out); | |
console.log("Done creating zip(gz) files."); | |
} else{ | |
console.log("Sorry, ecnountered problem while creating zip(gz) files."); | |
console.log(err); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment