JIT mode is not picking up changes unless I change tailwind.config.js file
What version of Tailwind CSS are you using?
v2.2.4
What build tool (or framework if it abstracts the build tool) are you using?
postcss-cli v8.3.1
What version of Node.js are you using?
v14.15.5
What browser are you using?
Firefox
What operating system are you using?
Windows
Reproduction repository
https://github.com/MohammadxAli/tailwind-test-repo
Describe your issue
Sometimes tailwind in jit mode is not adding classes to final CSS when I'm adding them to my HTML files unless I edit the tailwind.config.js file, I usually comment and uncomment some line in that file and all of sudden I see the class has been added to the CSS file, I had this very same issue on my Next.js project as well.
I made a new reproduction repository and tested things there, it was all good and working. Not really sure why it's not working on my own projects at some point. This may sound stupid but maybe tailwind is not picking up changes as the project get's more complicated? I made this issue to know if anyone had some similar experience or not, so maybe someone can guide me on how to resolve this.
Not to bloat this thread but I have just the same Issue with the exact same specs. Hot reloading is working but on JIT mode changes on tailwind styling fails on document save until you modify and save tailwind.config.js (on every change)
I tried to downgrade to 2.2.0 and 2.1.4 but behaviour is the same.
Same. Happening in my nextjs and vite projects. Tried to downgrade already but no luck. Its happening in a brand new vite project and a 1 year old nextjs project.
It works for like 10 minutes and then stops generating classes.
It works for like 10 minutes and then stops generating classes.
Not 100% the same issue here, but similar so I think it's worth to add. HMR stops working and the page is fully reloaded on every change (might be related: #4970 and #4968). If I disable JIT and run npm run dev (vite) it is working. Then, when I activate JIT and run npm run dev again, it is working and stops again after a while. Already tried the TAILWIND_MODE=watch without success.
Setup as following. Everything on the very latest versions.
Tailwind: v2.2.4
Build tool: Vite v2.42 with Post Css 8.3.5
Node: v16.5.0
Browser: Chrome v91
Operating System: macOS v11.4
Backend Laravel v8.50 on PHP 8
FWIW, there is a vite issue with how postcss registers all purgeable files as dependencies with dir-dependency :
https://github.com/vitejs/vite/issues/4150
There is a PR incoming :
https://github.com/vitejs/vite/pull/4267
In my case HMR does not work at all when I make modifications to JIT classes unless I stop the yarn serve process entirely and start it up again. Not using vite
In my case HMR does not work at all when I make modifications to JIT classes unless I stop the
yarn serveprocess entirely and start it up again. Not using vite
Can I ask you if you can reproduce this situation?
-
You serve your application make a change and save it on any class in JIT mode: -This brokes something in the render for example change
bg-red-500tobg-red-800and color goes out. -
You come back to
bg-red-500, save it and it returns back. But no "new changes" are applying on JIT mode
I am running into the same issue. I created a test repo from the NextJS with-tailwindcss example and it works fine, I see both red and green colors. As soon as I run it in my larger project HMR doesn't pick up changes. It sees the first group of colors hello-green in the extended theme, but not the second. The weird part is, if I delete hello-green and change hello-red to hello-green, I get all the text in red.
My larger project is typescript and NextJS.,
NextJS - v11 Tailwind - v2.2.4
module.exports = {
mode: 'jit',
purge: ['./pages/**/*.{js,ts,jsx,tsx}', './components/**/*.{js,ts,jsx,tsx}'],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {
colors: {
"hello-green": {
900: '#262E1F'
},
"hello-red": {
900: '#351911'
}
}
},
},
variants: {},
plugins: [],
}
I downgrade vite to 2.3.8,tailwind to 2.1.4,it works
same issue here on v2.2.4 with create-react-app -> using CRACO
Dev server needs to be stopped and started up again after every change.
same issue here on v2.2.4 with create-react-app -> using CRACO
@pingustar try the solution from #4768
@MohammadxAli I think I was able to reproduce this, but the classes do get picked up if I re-save the HTML file. Can you confirm whether this is the case for you?
@bradlc Yes that's true! I didn't realize that saving the same HTML files can also trigger picking up classes. But it's important to note that the contents of the file must be changed when re-saving, otherwise the classes won't be added.
I am now using tailwindcss with jit mode in a Laravel based project which I'm changing .blade.php files, the issue still exists. If classes are not added I need to change the contents of the same file which I used the new class in it or tailwind.config.js file.
Just to add an example from Tailwind UI, if you go to https://tailwindui.com/components/marketing/sections/heroes change the "Hero Section" title to "text-red-400" instead of text-grey-400 and the color goes blank (if you change the css class on the webpage not the code). Change it to another color and it also goes blank. Not sure if thats the intended affect.
Locally i can change the code and once i refresh the page itll change the color. But if i dont refresh the page, the css will change on the html automatically but the color wont show it, which kind of breaks local development with HMR.
I'm facing the same issue using Vite.
When creating an example to reproduce the issue, I noticed that it only happens when I set the base path in Vite. I need this option to integrate with Django.
I created a repo that demonstrates my observation https://github.com/Kostia-K/vite-tailwind-jit-issue
Hey all. I too was stumped by this issue while working on a Phoenix project last night. After finding this issue, I dug around a bit, and I have a workaround for Webpack pipelines.
As it turns out, Phoenix 1.5.9 uses webpack@4, which is incompatible with the latest versions of postcss-loader.
You need webpack v5 to use the latest version. For Webpack v4, you have to install postcss-loader v4.
https://webpack.js.org/loaders/postcss-loader/
Installing [email protected] resolved the issue in my project, and once again I can gleefully write Tailwind utils and see the changes in the browser quickly thanks to the JIT.
having the same issue, on nextjs 11.
Installing
[email protected]resolved the issue in my project, and once again I can gleefully write Tailwind utils and see the changes in the browser quickly thanks to the JIT.
Update: This only worked temporarily and I'm stumped.
As @Kostia-K mentioned, problems in Vite.js seem to be related to the usage of the base configuration option.
Related: https://github.com/ElMassimo/vite_ruby/discussions/115
Downgrading vite to 2.4.2 as mentioned before seems to fix the problem.
It seems like the problem started happening in [email protected], after this change: https://github.com/vitejs/vite/commit/89e3160d86bc8c27d6d33b82adec7c44016c3fc3#diff-2cfbd4f4d8c32727cd8e1a561cffbde0b384a3ce0789340440e144f9d64c10f6L194-R204
A potential fix here: https://github.com/vitejs/vite/pull/4592.