Skip to content

Commit

Permalink
handle clean-css errors correctly (#955)
Browse files Browse the repository at this point in the history
Latest version of `clean-css` no longer throws processing errors.
  • Loading branch information
felipemsantana authored and alexlamsl committed Aug 23, 2018
1 parent dcb6941 commit df720b3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/htmlminifier.js
Expand Up @@ -664,13 +664,12 @@ function processOptions(values) {
text = text.replace(/(url\s*\(\s*)("|'|)(.*?)\2(\s*\))/ig, function(match, prefix, quote, url, suffix) {
return prefix + quote + options.minifyURLs(url) + quote + suffix;
});
try {
return unwrapCSS(new CleanCSS(value).minify(wrapCSS(text, type)).styles, type);
}
catch (err) {
options.log(err);
var cleanCssOutput = new CleanCSS(value).minify(wrapCSS(text, type));
if (cleanCssOutput.errors.length > 0) {
cleanCssOutput.errors.forEach(options.log);
return text;
}
return unwrapCSS(cleanCssOutput.styles, type);
};
}
else if (key === 'minifyJS' && typeof value !== 'function') {
Expand Down

0 comments on commit df720b3

Please sign in to comment.