question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect media query concats

See original GitHub issue
@import "ignore.css" (min-width: 25em);
/* ignore.css */
@import "http://css-screen" screen;

Becomes :

@import "http://css-screen" (min-width: 25em) and screen;

Should be :

@import "http://css-screen" screen and (min-width: 25em);

It might be interesting to adopt our media query parser : https://github.com/csstools/postcss-plugins/tree/postcss-preset-env--v8/packages/media-query-list-parser#readme

It has a typed object model which makes it easier to avoid these issues.


Alternatively it is possible to “special case” these keywords :

  • screen
  • print
  • all
  • not

And then sorting the media query lists :

  1. these keywords first
  2. everything else later
  3. join with and

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
romainmenkecommented, Dec 4, 2022

Thank you for trusting me with this package 🎉

Yes I also prefer to do PR’s, it so valuable to have another opinion on changes 😃

1reaction
RyanZimcommented, Dec 1, 2022

In that case, I think I’ll merge your regex hack and see if anyone complains 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Media Queries breakpoint at wrong value - css - Stack Overflow
I checked my reset css, I have the latest version of normalize.css... I have already used that structure of media query previously and...
Read more >
Media Queries Level 5 - W3C
A media query is a logical expression that is either true or false. A media query is true if: the media type, if...
Read more >
Beginner's guide to media queries - Learn web development
The CSS Media Query gives you a way to apply CSS only when the browser and device environment matches a rule that you...
Read more >
How to Use Email Media Queries Across Different Email Clients
Learn how to use email media queries to create responsive email for different screen sizes and mobile devices. See email client support for...
Read more >
Logic in CSS Media Queries (If / Else / And / Or / Not)
My problem is that the last Media Query is overriding everything. I can't seem to figure out why. I would have thought that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found