Investigating Inconsistent Config Loading with @tailwindcss/vite #18469
-
Hello Tailwind Team, First of all, thank you for all the incredible work on v4. The new engine and the dedicated Vite plugin are exciting developments. I was recently setting up a new project to try out To understand it better, I created a minimal reproduction repository, which can be found here: To trace the issue, I also cloned the The minimal repo uses a standard setup, but with one key feature: the main CSS file is in a subdirectory ( The Core ObservationWhen I run the MRE, I see very specific and seemingly contradictory behavior:
This suggests that the config file is being found and read, but that the The Debugging TraceMy logging within the local builds revealed a very specific chain of events that seems to cause this:
Summary of Findings: It appears there are two separate config-loading mechanisms at play. One process seems to correctly find A Few QuestionsThis deep dive left me with a few questions about the intended design, which would be super helpful to understand:
Thank you again for your time and for looking into this. I'm really excited about where the project is headed! Environment
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
What is happening is that you've configured Tailwind v4 using v3 methods. In v4, the V4 has automatic source scanning. Thus, it finds So then why does Tailwind not output the classes in If we followed the vite integration instructions and replaced your CSS file with: @import "tailwindcss"; This is shorthand for: @layer theme, base, components, utilities;
@import "tailwindcss/theme.css" layer(theme);
@import "tailwindcss/preflight.css" layer(base);
@import "tailwindcss/utilities.css" layer(utilities); Which imports the default theme tokens as mentioned previously. Thus, having your @import "tailwindcss"; Should now see all the expected class names in the output CSS file. |
Beta Was this translation helpful? Give feedback.
-
Thanks @wongjn extremely helpful! |
Beta Was this translation helpful? Give feedback.
What is happening is that you've configured Tailwind v4 using v3 methods. In v4, the
tailwind.config.js
is phased out and is not the main container for configuration any more.V4 has automatic source scanning. Thus, it finds
rotate-12
as a string insidetailwind.config.js
, not that it loads thesafelist
as configuration. So, it addsrotate-12
to the CSS output.So then why does Tailwind not output the classes in
index.html
,text-3xl
,font-bold
andtext-blue-500
? This is because all of these classes rely on named Tailwind theme tokens for--font-size
,--font-weight
and--color
. However, these do not exist in Tailwind compilation runs in your reproduction. This is because you haven't includ…