Skip to content

Commit

Permalink
Support passing options to html-minifier
Browse files Browse the repository at this point in the history
  • Loading branch information
astronomersiva committed Dec 29, 2018
1 parent 15ce051 commit 50ba7cb
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/utils/minifyHtml.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
const findUp = require('find-up');
const { minify } = require('html-minifier');

let configFile = findUp.sync('lego.js');
let config = {
collapseWhitespace: true,
minifyJS: true,
minifyCSS: true,
removeComments: true
};

if (configFile) {
config = Object.assign(config, require(configFile).htmlMinifier);
}

module.exports = function(html, isDevelopment) {
try {
if (isDevelopment) {
return html;
}

return minify(html, {
collapseWhitespace: true,
minifyJS: true,
minifyCSS: true,
removeComments: true
});
return minify(html, config);
} catch (error) {
throw error;
}
Expand Down

0 comments on commit 50ba7cb

Please sign in to comment.