diff --git a/bin/npm-html2js.js b/bin/npm-html2js.js
index 6063f4d..1da65a9 100755
--- a/bin/npm-html2js.js
+++ b/bin/npm-html2js.js
@@ -9,12 +9,12 @@ var args = process.argv.slice(2);
var templateModule = fs.readFileSync(path.join(__dirname, './../tmpl/templateModule.tmpl'), 'utf-8');
var templateCache = fs.readFileSync(path.join(__dirname, './../tmpl/templateCache.tmpl'), 'utf-8');
-var usage = fs.readFileSync(path.join(__dirname, './../tmpl/usage.md')).toString()
+var usage = fs.readFileSync(path.join(__dirname, './../tmpl/usage.md')).toString();
var opts = {};
opts.extension = 'html';
-opts.tplPath = '**/*.tpl.'
-opts.moduleName = 'app.template'
+opts.tplPath = '**/*.tpl.';
+opts.moduleName = 'app.template';
var arg;
while (args.length) {
@@ -27,38 +27,53 @@ while (args.length) {
break;
case '-i':
case '--input':
- opts.tplPath = args.shift()
+ opts.tplPath = args.shift();
break;
case '-o':
case '--output':
- opts.filename = args.shift()
+ opts.filename = args.shift();
break;
case '-e':
case '--exclude':
- opts.exclude = args.shift()
+ opts.exclude = args.shift();
break;
case '-m':
case '--module':
- opts.moduleName = args.shift()
+ opts.moduleName = args.shift();
break;
case '-b':
case '--base':
- opts.basePath = args.shift()
+ opts.basePath = args.shift();
break;
case '-q':
case '--quotes':
- opts.quotes = true
+ opts.quotes = true;
break;
case '--minify':
- opts.minify = true
+ opts.minify = true;
+ break;
+ case '--collapseBooleanAttributes':
+ opts.collapseBooleanAttributes = (args.shift() !== 'false');
+ break;
+ case '--collapseWhitespace':
+ opts.collapseWhitespace = (args.shift() !== 'false');
+ break;
+ case '--conservativeCollapse':
+ opts.conservativeCollapse = (args.shift() !== 'false');
+ break;
+ case '--removeComments':
+ opts.removeComments = (args.shift() !== 'false');
+ break;
+ case '--minifyInlineCss':
+ opts.minifyInlineCss = (args.shift() !== 'false');
break;
default:
break;
}
}
-opts.output = (opts.filename) ? path.join(process.cwd(), opts.filename) : null
+opts.output = (opts.filename) ? path.join(process.cwd(), opts.filename) : null;
opts.tplPath = (opts.tplPath === '**/*.tpl.') ? opts.tplPath + opts.extension : opts.tplPath;
-html2js(opts)
+html2js(opts);
diff --git a/package.json b/package.json
index 0b8e44d..47a3f4b 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,7 @@
"chai": "^1.10.0",
"combined-stream": "0.0.7",
"glob": "^4.3.2",
- "htmlmin": "0.0.4",
+ "html-minifier": "3.2.3",
"jade": "^1.8.2",
"through2": "^0.6.3"
},
diff --git a/src/index.js b/src/index.js
index 34cc2f7..a7664da 100644
--- a/src/index.js
+++ b/src/index.js
@@ -4,7 +4,7 @@ var glob = require('glob')
var jade = require('jade');
var path = require('path');
var util = require('util');
-var htmlmin = require('htmlmin');
+var htmlminify = require('html-minifier').minify;
var templateModule = fs.readFileSync(path.join(__dirname, './../tmpl/templateModule.tmpl'), 'utf-8');
var templateCache = fs.readFileSync(path.join(__dirname, './../tmpl/templateCache.tmpl'), 'utf-8');
@@ -21,6 +21,11 @@ module.exports = function (opts, callback) {
var quotes = opts.quotes;
var exclude = opts.exclude || '';
var minify = opts.minify;
+ var collapseBooleanAttributes = opts.collapseBooleanAttributes !== undefined ? opts.collapseBooleanAttributes : true;
+ var collapseWhitespace = opts.collapseWhitespace !== undefined ? opts.collapseWhitespace : true;
+ var conservativeCollapse = opts.conservativeCollapse !== undefined ? opts.conservativeCollapse : false;
+ var removeComments = opts.removeComments !== undefined ? opts.removeComments : true;
+ var minifyInlineCss = opts.minifyInlineCss !== undefined ? opts.minifyInlineCss : true;
function processFileData(route, html) {
@@ -29,10 +34,12 @@ module.exports = function (opts, callback) {
if (route.indexOf('.jade') !== -1)
html = jade.render(html, {pretty: true});
if (minify)
- html = htmlmin(html, {
- collapseBooleanAttributes: true,
- collapseWhitespace: true,
- removeComments: true
+ html = htmlminify(html, {
+ collapseBooleanAttributes: collapseBooleanAttributes,
+ collapseWhitespace: collapseWhitespace,
+ conservativeCollapse: conservativeCollapse,
+ removeComments: removeComments,
+ minifyCSS: minifyInlineCss
});
html = html.replace(/\\/g, '\\\\');