Skip to content

Instantly share code, notes, and snippets.

@bloodyowl
Created October 5, 2013 21:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bloodyowl/6846108 to your computer and use it in GitHub Desktop.
Save bloodyowl/6846108 to your computer and use it in GitHub Desktop.
Minify HTML files using nodeJS
var minify = require("minify")
, fs = require("fs")
, htmlRegExp = /\.html$/
, options = {encoding:"utf-8"}
fs.readdirSync("./dist").filter(isHTML).forEach(write)
function isHTML(item){
return htmlRegExp.test(item)
}
function write(fileName){
minify.optimize("./dist/" + fileName, {
callback : function(data){
fs.writeFileSync("./dist/" + fileName, data, options)
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment