Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JIT] unused CSS not eliminated in watch mode #4098

Closed
mainej opened this issue Apr 17, 2021 · 4 comments
Closed

[JIT] unused CSS not eliminated in watch mode #4098

mainej opened this issue Apr 17, 2021 · 4 comments

Comments

@mainej
Copy link

mainej commented Apr 17, 2021

What version of Tailwind CSS are you using?

2.1.1

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

postcss-cli 8.3.1

What version of Node.js are you using?

v14.7.0

What browser are you using?

Firefox

What operating system are you using?

macOS

Reproduction repository

https://github.com/mainej/tailwind-jit-dead-code

Describe your issue

In JIT watch mode, when the last instance of a class is removed from the source files, I would expect that the class would be removed from the compiled CSS. However, there must be some caching that keeps it around. See the README.md in the attached repository for steps to reproduce.

In most cases it isn't a problem to have extra style definitions in the compiled CSS, but it runs counter to the advertised property that with the JIT, your development CSS is exactly the same as your production CSS.

@adamwathan
Copy link
Member

Hey! This is currently by design, see previous discussion here:

tailwindlabs/tailwindcss-jit#57

It's considerably faster and allows rebuilds in watch mode to be 5-10ms instead of several hundred ms. May change this eventually but right now it is deliberate — the types of dev vs production differences you would see from this are not real problems IMO, unlike the bg-${color}-500 type of bugs you can run into using regular Tailwind + purge.

@mainej
Copy link
Author

mainej commented Apr 17, 2021

Cool, thanks for the explanation and for keeping rebuilds fast. It's good to know that I can touch tailwind.config.js if I really want to bust the cache.

@adamwathan
Copy link
Member

Yeah you can also just hit save in your main CSS file too 👍🏻

@harvanchik
Copy link

I thought this was a bug until I found this bug report. I didn't see this in the documentation of JIT. Maybe make this known on the JIT Page? I'm glad I found this answer though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants