Skip to content

removeDuplicateRules #1188

Answered by jakubpawlowicz
Uvatek asked this question in Q&A
Oct 14, 2021 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hello @Uvatek !

There are two removeEmpty flags - in level 1 and level 2. In your case you can skip level 1 flag and just use level 2 flag:

var options = { level: { 2: { all: false, removeEmpty: true, removeDuplicateRules: true, removeUnusedAtRules: true } } }; var output = new CleanCSS(options).minify(['test.css', 'test2.css'])

The reason is only level 2 optimizations can figure out a{font-weight:700} is repeated - in fact it's font-weight: 700 which is overridden in second a{... block so it can be dropped in first one, then in another pass the first a{} can be dropped.

Hope this helps!

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Uvatek
Comment options

@jakubpawlowicz
Comment options

Answer selected by Uvatek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants