Created
October 5, 2013 21:14
-
-
Save bloodyowl/6846108 to your computer and use it in GitHub Desktop.
Minify HTML files using nodeJS
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 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