mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-14 09:39:15 +00:00
Instead of replacing empty rules with comments, remove them.
This commit is contained in:
@@ -126,25 +126,14 @@ module.exports = class CrittersWebpackPlugin {
|
|||||||
sel = sel.replace(/::?(?:[a-z-]+)([.[#~&^:*]|\s|\n|$)/gi, '$1');
|
sel = sel.replace(/::?(?:[a-z-]+)([.[#~&^:*]|\s|\n|$)/gi, '$1');
|
||||||
return document.querySelector(sel, document) != null;
|
return document.querySelector(sel, document) != null;
|
||||||
});
|
});
|
||||||
// If there are no matched selectors, replace the rule with a comment.
|
// If there are no matched selectors, remove the rule:
|
||||||
if (rule.selectors.length===0) {
|
if (rule.selectors.length===0) {
|
||||||
rule.type = 'comment';
|
return false;
|
||||||
rule.comment = '';
|
|
||||||
delete rule.selectors;
|
|
||||||
delete rule.declarations;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rule.rules) {
|
// If there are no remaining rules, remove the whole rule.
|
||||||
// Filter out comments
|
return !rule.rules || rule.rules.length!==0;
|
||||||
rule.rules = rule.rules.filter(notComment);
|
|
||||||
// If there are no remaining rules, replace the parent rule with a comment.
|
|
||||||
if (rule.rules.length===0) {
|
|
||||||
rule.type = 'comment';
|
|
||||||
rule.comment = '';
|
|
||||||
delete rule.rules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
sheet = css.stringify(ast, { compress: this.options.compress!==false });
|
sheet = css.stringify(ast, { compress: this.options.compress!==false });
|
||||||
|
|||||||
Reference in New Issue
Block a user