Tailwind CSS module unexpected style apply
Hi everyone,
I'm facing an issue with using Tailwind CSS in my project. My setup includes Nuxt 3.12.2, and I'm using the @nuxtjs/tailwindcss module version 6.12.0, both of which are the latest versions.
When I create a new page [test.vue] under the pages directory and add Tailwind CSS class names, HMR allows me to view the /test page. However, the Tailwind CSS styles are not being applied.
test.vue
This problem only occurs when I add a new file and use Tailwind CSS class names that haven't been used before.
I would like to ask if I've done something wrong or missed any settings. Thank.
demo:
https://stackblitz.com/edit/nuxt-starter-dttqi3
amonys19212
StackBlitz
Nuxt - Starter (forked) - StackBlitz
Create a new Nuxt project, module, layer or start from a theme with our collection of starters.
19 Replies
The stackblitz shows everything working properly
I see the issue too. If you add a new page it won't apply the style. Only to existing pages for some reason
I reran dev and everything was good. It may just be a stackblitz issue
@Ryän does it help if you add a tailwind config?
I think it just needs to be restarted after adding the new file so the new file gets added to the watch
Hot reloading and everything is working fine for me locally once it detects the new file
Adding the tailwind.config.js does let it detect the new files without needing a restart
I do usually use one as well
I cannot get it to work with either the default settings or the following settings.
I encountered this issue during local development and then tested and reproduced it on Stackblitz.
If you add a new page it won't apply the style. Only to existing pages for some reason
Can you try adding a tailwind.config.js?
I saw that it didn't detect new pages without that
let me try your config
Using the config you provided, the same error still occurs.
Perhaps, as you mentioned, it is not detecting the newly added page.
You can try starting the project with npm run dev, then adding a new page and navigating to the route.
Yeah, it might just be a stackblitz thing, though
It works fine locally
Stackblitz has some stuff that just doesn't work
I'm actually seeing it apply the classes, and then it gets removed
so something weird is going on in stackblitz
I encountered this issue during local development. What other information can I provide to help you?
Hmm, yeah, I can see this as well
Huh... I guess it just doesn't detect new pages until the server restart
I've never even noticed that before
ha
I guess I just use a lot of the same classes
maybe its the new version of tailwind
I'm using 3.4
I don't think that's it
It makes sense that it wouldn't know new files are there by default
i think its ok, its not part of the hmr workflow to add new pages alot
I did send a bad config, though
It needs the preceeding .
I tried using an older version of the Tailwind CSS module, version 6.11.3, and everything worked fine, including new class names in newly added files.
I believe the issue is caused by the new First HMR feature introduced in version 6.12.0.
p.s. I mistakenly mentioned the problematic version as 3.12.0. The correct version is 6.12.0, which is causing the issue.
the content paths include the pages directory and that should trigger invalidation of tailwind cache - let me investigate!
I saw the sand thing with a manual tailwind install, so I don’t think it’s the module