Skip to content

Minifying CSS with 0.25.11 can lead to missing media query related code #4315

@rbsummers

Description

@rbsummers

Hi!

I think I've encountered a bug in v0.25.11 during minification of CSS code. Given the following CSS as foo.css:

@media only screen and (max-width: 1px) {
  .problematic {
    font-family: sans-serif;
    font-weight: 350;
    font-size: 10px;
    letter-spacing: 0.025em;
    line-height: 100%;
    font-family: sans-serif;
    font-weight: 700;
  }
}
@media only screen and (min-width: 2px) and (max-width: 3px) {
  .problematic {
    font-family: sans-serif;
    font-weight: 350;
    font-size: 12px;
    letter-spacing: 0.025em;
    line-height: 100%;
    font-family: sans-serif;
    font-weight: 700;
  }
}
@media only screen and (min-width: 4px) {
  .problematic {
    font-family: sans-serif;
    font-weight: 350;
    font-size: 10px;
    letter-spacing: 0.025em;
    line-height: 100%;
    font-family: sans-serif;
    font-weight: 700;
  }
}

When I run esbuild --minify foo.css with v0.25.11, the first media query is removed, meaning that the output code will only contain code related to the second and third media queries. It does not happen on v0.25.10.

Image

I know the repeated properties look weird but they do certainly play some part of it, because if for example I remove the repeated font-family from the first block, the output is as expected. It's also the same with having 3 media queries and I cannot reproduce the issue with only 2. This is of course a synthetic scenario, but in my real use case this makes sense because I have some SASS mixins that are external to me and I need to apply for my styling.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions