postcss / autoprefixer

Parse CSS and add vendor prefixes to rules by Can I Use
https://twitter.com/autoprefixer
MIT License
21.57k stars 1.25k forks source link

🐛 Media queries issue with older browsers #1504

Closed Edgaras98 closed 6 months ago

Edgaras98 commented 6 months ago

I have a problem with older browsers, especially on Safari.

I write CSS syntax like this:

@media (width <= 768px) {
      width: 100%;
}

I get compiled output as:

@media (width <= 768px) {
      width: 100%;
}

I would expect that to be compiled into:

@media (max-width: 768px) {
      width: 100%;
}

This is my configuration in package.json:

"browserslist": [
        "last 5 Chrome versions",
        "iOS >= 15.5",
        "last 2 Firefox versions",
        "last 1 ChromeAndroid versions",
        "Safari >= 15.5",
        "not dead"
],

I would expect that autoprefixer would compile into older syntax on versions that do not support newer ones.

you can even see this issue on: https://autoprefixer.github.io/

ai commented 6 months ago

You need a polyfill (postcss-preset-env) not a Autoprefixer for that.

More details https://github.com/postcss/autoprefixer#does-it-add-polyfills