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.

JIT removes classes that are used when the selector is combined with a class that isn't used

See original GitHub issue

What version of Tailwind CSS are you using?

2.2.4

What build tool (or framework if it abstracts the build tool) are you using?

N/A

What version of Node.js are you using?

N/A

What browser are you using?

N/A

What operating system are you using?

N/A

Reproduction repository

https://play.tailwindcss.com/g8MOeRe8bW?file=css

Describe your issue

If you have:

@layer base {
  .works, .oh-no {
    color: red;
  }
}

and you do:

<div class="works">Hello</div>

The text will not be red. JIT needs to also find oh-no for the .works, .oh-no { ... } selector to work.

Don’t know if this is by design or not but it threw me off because if you don’t use JIT and just use Purge it still works.

I figured I’d open an issue to discuss.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
RobinMalfaitcommented, Sep 27, 2021

Hey! Thank you for your bug report! Much appreciated! 🙏

Good that you included a reproduction repo, because the example you shared in the description does work: https://play.tailwindcss.com/aXTe2gAlX6?file=css

The issue here is that we extract class candidates only. So if you are using :root (your issue) or [attributeName] (@mgibas’ issue) or other selectors that are not related to classes, then we don’t match them and thus not generate them.

I’ll see if I can come up with a nice fix here, thanks!

1reaction
adamwathancommented, Sep 28, 2021

This is fixed and can be tested in the insiders build if you want to play with it now 👍🏻

npm i -D tailwindcss@insiders

Will be in v3, and likely not backported to v2 since it’s a JIT-only thing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JIT removes classes that are used when the selector is combined ...
JIT removes classes that are used when the selector is combined with a class that isn't used.
Read more >
Just-in-Time Mode - Tailwind CSS
Styles aren't removed when classes are deleted. When the JIT engine is running in watch mode, you might notice that when you add...
Read more >
Tailwind CSS classes is not working in my project?
This error is due to tailwind not finding any classes to scan in what it 'thinks' is your HTML code directories.
Read more >
TailwindCSS: Adds complexity, does nothing.
Then, in every component that needs to be flexed, you add that "flex" class. This is not a bad thing. I have written,...
Read more >
Why I Don't Like Tailwind CSS | Aleksandr Hovhannisyan
But they actually correspond to a little-used align-content property. ... chain 12 Tailwind classes because there are three selectors.
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