Open jfbrennan opened 1 year ago
We already merge adjacent media queries, but non-adjacent rules cannot be merged safely without changing the order of the rules and thus potentially changing the behavior.
True. If the order mattered that wouldn't work. I haven't written cascading rules for maybe 6-7 years. Make it opt-in?
Would like to see this feature as an option. Ordering can impact the specificity but I've not had this problem in the past when using. More complex when CSS Nesting is involved. Understandable to want to skip this however, so I'm just expressing an interest. Great project by the way, thanks
It seems like there's an optimization to be had by grouping rules from the same media queries. For example, I'm working on dark mode for a project and the minified stylesheet has six instances of
@media screen and (prefers-color-scheme:dark){}
. Five of those could have been removed from the output (that's 235 characters, and I'm still creating more). I can see other media queries where this should be the case as well.Perhaps there's an edge case(s) that prevent this from being doable, but if I manually merge my six instances into one everything still works.