search

Home  >  Q&A  >  body text

Parcel incorrectly rewrites media queries

<p>I'm currently using Parcel 2.8.3 and @parcel/transformer-sass 2.8.3, but I'm having some issues with the way I'm rewriting media queries. In my previous projects using Parcel, I had no such issues and everything was as it should be. </p> <p>This is the SASS file: </p> <pre class="brush:php;toolbar:false;">h1 { color: red; } @media only screen and (max-width: 40em) { h1 { color: blue; } }</pre> <p>This is the CSS output: </p> <pre class="brush:php;toolbar:false;">h1 { color: red; } @media only screen and (width <= 40em) { h1 { color: #00f; } }</pre> <p>As you can see, the media query in the CSS file has been changed from max-width to width <= 40em, which does not work when viewed on an actual mobile phone. </p> <p>If I use package-lock.json and package.json copied from a 1 month old project, the media queries are rewritten as they should be. As shown above, when running <code> npm i Parcel & npm i @parcel/transformer-sass</code> for my new project, when I launch the project, all the media queries change as in the second code block shown. Any suggestions would be great. </p>
P粉722521204P粉722521204452 days ago555

reply all(1)I'll reply

  • P粉426780515

    P粉4267805152023-08-31 12:34:46

    I found a solution to extend the browser list. Add the following to your package.json:

    "browserslist": "> 0.5%, last 3 versions, not dead"

    This will extend supported browsers and should ensure it is not overwritten and older Safari can handle it.

    reply
    0
  • Cancelreply