trullock / NUglify

NUglify is a HTML, JavaScript and CSS minification Library for .NET (fork of AjaxMin + new features)
Other
390 stars 79 forks source link

Minify css: range selector media queries/container queries #386

Open hajerty opened 4 months ago

hajerty commented 4 months ago

Hi, I'm using 1.20.0.0 and I'm finding a problem when I try to minify a css file with media queries rules. In detail, I have this rule @container (min-width: 480px) and (max-width: 1024px) and the minified version is @container (min-width: 480px) and(max-width: 1024px) .

To minify I use this code: NUglify.Uglify.Css(text) without any setting.

Could you help me to find a way to avoid that the space after the and word is cancelled? Thanks

trullock commented 4 months ago

@Container is completely unsupported as its a relatively new CSS feature.

PR welcome

Modify CssScanner.cs and add "CONTAINER" support to ScanAtKeyword(), then CssParser.cs needs a method to handle it called from at least ParseStylesheet()

DarthSonic commented 3 months ago

Very similar issue here:

@container fooName (min-width: 480px) gets @container fooName(min-width: 480px)

missing a space after fooName and therefore becoming invalid syntax.

trullock commented 3 months ago

Yeah it's probably the same fix.

PRs welcome

Chlorobyte-but-real commented 1 month ago

Same issue can be reproduced with @media not (prefers-color-scheme: dark)

trullock commented 1 month ago

Thanks for the extra test case. Again PRs welcome