Skip to content

CSS minifier produces invalid output for @media rules #4395

Closed

Description

@BenjaminCubbage

See here:

https://esbuild.github.io/try/#dAAwLjI3LjMALS1taW5pZnkgLS1sb2FkZXI9Y3NzAEBtZWRpYSBvbmx5IHNjcmVlbiBhbmQgKChtaW4td2lkdGg6IDEwcHgpIG9yIChtaW4taGVpZ2h0OiAxMHB4KSkgewogIGNvbG9yOiBibHVlOwp9

Input:

@media screen and ((min-width: 10px) or (min-height: 10px)) {
    color: blue;
}

Minified output:

@media only screen and (min-width:10px)or (min-height:10px){color: blue}

Expected output:

@media only screen and ((min-width:10px)or (min-height:10px)){color: blue}

Note the absence of nested parentheses in the actual output.

This results in the media query doing nothing in Chrome and Firefox, and violates CSS specification, which states 'or' and 'and' clauses cannot share the same level of "nestedness".

Activity

  1. changed the title [-]CSS minifier produces invalid output for @media queries[/-] [+]CSS minifier produces invalid output for @media rules[/+] on Feb 14, 2026
  2. added a commit that references this issue on Feb 22, 2026
    65c401f
  3. added a commit that references this issue on Mar 10, 2026
    4384bad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions