mattbasta / crass

A CSS minifier and utility library for JavaScript
http://mattbasta.com/crass
MIT License
102 stars 6 forks source link

Merge duplicate @media rules #58

Closed JacobEvelyn closed 7 years ago

JacobEvelyn commented 7 years ago

My build chain produces CSS that looks like this:

.foo {
  color: "#333";
}
.bar {
  color: "#ddd";
}
@media screen and (max-width:50pc) {
  .foo {
    color: "#444";
  }
}
@media screen and (max-width:50pc) {
  .bar {
    color: "#eee";
  }
}

I noticed that crass doesn't combine the two @media rules into a single one. Is that something others would value? Should I look at the code and try to come up with a pull request?

mattbasta commented 7 years ago

Thanks for the issue! Let me take a quick look and see if it's something I can knock out fast.

mattbasta commented 7 years ago

This should be fixed in crass@0.10.4

Thanks for reporting it!

JacobEvelyn commented 7 years ago

Amazing, thanks!

soluml commented 4 years ago

@mattbasta Thoughts on taking this same logic and applying it to @supports?

mattbasta commented 4 years ago

@soluml Can you file a new issue? I'm rewriting everything in TypeScript, and I can include this in the final rewrite.