CssMin icon indicating copy to clipboard operation
CssMin copied to clipboard

at-media + at-keyframes not minified correctly

Open firewizard opened this issue 8 years ago • 5 comments

Minifier break css when at-media & at-keyframes are used together.

This css:

@media (min-width: 0) and (max-width: 360px) {
    @keyframes loop {
        0% {
            transform: translateX(0);
        }
        100% {
            transform: translateX(calc(-100% + 360px));
        }
    }
}

@media (min-width: 480px) {
    @keyframes loop {
        0% {
            transform: translateX(0);
        }
        100% {
            transform: translateX(calc(-100% + 480px));
        }
    }
}

.a {
    color: red
}

when minified and then re-formatted, produces this result:

@media (min-width: 0) and (max-width: 360px) {
    @keyframes loop {
        0% {
            transform: translateX(0)
        }
        100% {
            transform: translateX(calc(-100% + 360px))
        }
    }@media (min-width: 480px) {
    @keyframes loop {
        0% {
            transform: translateX(0)
        }
        100% {
            transform: translateX(calc(-100% + 480px))
        }
    }
} .a {
      color: red
  }

Notice the missing "}". If there's only one at-media + at-keyframes block, it works well, if there are more, it breaks all of them except the last one.

firewizard avatar Oct 31 '16 15:10 firewizard

Hi firewizard, can you make a pull request to fix this issue please? Thanks!

natxet avatar Oct 31 '16 16:10 natxet

That's the problem, I wasn't able to figure out a fix for this, otherwise I would've opened a PR instead of an issue.

firewizard avatar Oct 31 '16 16:10 firewizard

;-) Sorry, I'm just maintaining this repo, I wish I could help, lets see if someone can figure it out!

natxet avatar Oct 31 '16 17:10 natxet

same problem with @supports block

@supports (-ms-overflow-style: none) { .ps { overflow: auto !important; } }

produces:

@supports (-ms-overflow-style: none){.ps { overflow:auto !important}

there's missing last curly bracket

yess-webioza avatar Sep 20 '18 13:09 yess-webioza

Also see #29

Ruud-Zuiderlicht avatar Jan 02 '19 13:01 Ruud-Zuiderlicht