Parcel incorrectly rewrites media queries
P粉722521204
P粉722521204 2023-08-30 16:22:21
0
1
581
<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粉722521204
P粉722521204

reply all(1)
P粉426780515

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template