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.

Adding Critters to project removes media queries from external stylesheet

See original GitHub issue

I’m using Critters in my webpack project with the following configuration:

new Critters({
  mergeStylesheets: true,
  inlineFonts: true,
})

I’m using this in combination with MiniCssExtractPlugin. When I add Critters to the plugin list (after MiniCssExtractPlugin and HtmlWebpackPlugin), critters seems to remove the content of media queries - the output still has the media queries but nothing is in them, which looks like this:

@media (max-width: 480px) {}

This breaks the styling and layout of my site.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

2reactions
jaydiablocommented, Jul 8, 2019

I can also confirm that changing pruneSource from true (the default) to false fixes the issue of CSS inside media queries being removed.

1reaction
fpapadocommented, Apr 9, 2019

I know, I was mentioning it in case it was something actionable; I don’t know the things you are building, not pruning could very well have a large effect there 😃

For the maintainers: I’ve also had this issue when pruneSource is on.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Do CSS media queries have to be in an external CSS file?
Media queries are perfectly valid within <style> , they don't have to be within an external stylesheet. Make sure you include the viewport ......
Read more >
node_modules/critters · master · Zahra Hassanjoulaee / Alice app ...
Critters is a plugin that inlines your app's critical CSS and lazy-loads the ... and media queries; Removes inlined CSS rules from lazy-loaded...
Read more >
Creating a Future-Proof Responsive Email Without Media ...
This tutorial is all about creating a great experience in email clients which have no nested CSS or media query support whatsoever, using...
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 >
A Webpack Plugin to inline Your Critical CSS & Lazy-load The Rest
"body": Move all external stylesheet links to the end of the document. "media": Load stylesheets asynchronously by adding media="not x" and removing once ......
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