lightningcss icon indicating copy to clipboard operation
lightningcss copied to clipboard

minifier: remove duplicate selectors

Open yisibl opened this issue 3 years ago • 6 comments

h1,h2,h3,h1,h3{
  color:blue
}

div.class,div.class,.class{
  color:blue
}

https://parcel-css.vercel.app/#%7B%22minify%22%3Atrue%2C%22nesting%22%3Atrue%2C%22customMedia%22%3Atrue%2C%22cssModules%22%3Afalse%2C%22analyzeDependencies%22%3Afalse%2C%22targets%22%3A%7B%22chrome%22%3A6225920%7D%2C%22source%22%3A%22h1%2Ch2%2Ch3%2Ch1%2Ch3%7B%5Cn%20%20color%3Ablue%5Cn%7D%5Cn%5Cndiv.class%2Cdiv.class%2C.class%7B%5Cn%20%20color%3Ablue%5Cn%7D%22%2C%22unusedSymbols%22%3A%5B%5D%2C%22version%22%3A%22local%22%7D

yisibl avatar Jul 22 '22 09:07 yisibl

Seems reasonable. When does this happen in real-world code though?

devongovett avatar Jul 31 '22 17:07 devongovett

Seems reasonable. When does this happen in real-world code though?

I'm not quite sure if there might be such a code, my guess is that it might be a clerical error or generated by the preprocessor.

yisibl avatar Aug 17 '22 15:08 yisibl

I'd like to take a look at this one.

LeoniePhiline avatar Oct 31 '22 21:10 LeoniePhiline

I won't manage currently to work on this. Free to take!

LeoniePhiline avatar Dec 01 '22 16:12 LeoniePhiline

For anybody still looking for a solution here, I've managed to combine cssnano and postcss-lightningcss to achieve the desired result. Note that this will require postcss.

R-Bower avatar Mar 17 '23 19:03 R-Bower

I'd like to have a try

qsliu2017 avatar Mar 09 '24 14:03 qsliu2017