-
Notifications
You must be signed in to change notification settings - Fork 4.5k
4.0.8 is a break update, many styles don't work after upgrading in the Astro project #16733
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
Comments
Same issue when update to 4.0.8, class like
|
I believe it is related to this change: #16631 Moving away from module-graph for discovering class names breaks monorepo setups that rely on it. I wish it was configurable. |
Create the tailwind.config.js file in the root of your project.
But if you mean that some classes are broken, I should say that you should take a look at the Tailwind documentation because some classes have been shortened and changed. |
Just started seeing this. I have a monorepo where my app directory imports from a shared pacakge that has a lot of tailwind classes. None of those classes are generated anymore. I wonder if #16631 needs to parse package.json or something to figure out which files to scan. Seems a little risky though. Also think it might be smart to make configurable for monorepo setups |
Hey folks! Yeah unfortunately with the latest updates we have had to make the Vite plugin function exactly like the PostCSS plugin now (in terms of how it finds source locations). That means that if you want to scan a folder outside of your Vite root or inside any of your git-ignored directories, you need to use We tried to get away with doing something smarter on Vite but we've been running into many much more subtle issues (where production builds would sometimes end up with a different set of styles than dev builds etc.) so we had to make these bigger changes for now unfortunately. I'll do more investigation next week to see if there are any more things we can do here but for now add |
Hey @philipp-spiess, Thank you for your answer - in my turborepo, I tried using @import 'tailwindcss';
@import '@repo/tailwind-config/style.css';
@source '../../../tools/tailwind'; However, this still breaks in v4.0.8. Edit: even when changing it to: @import '../../../tools/tailwind/style.css';
@source '../../../tools/tailwind';
/* Or */
@import '../node_modules/@repo/tailwind-config/style.css';
@source "../node_modules/@repo/tailwind-config"; the styling still does not work. |
@nktnet1 I had to move style.css into our app packages (basically creating style.css for each app), then relatives imports worked. |
I have a shared tailwind style.css that's meant to be re-used as a base across many different apps in the turborepo, so unfortunately this won't be a viable solution. Thanks for sharing though. Will need to lock version to 4.0.7 for now :/. |
@nktnet1 actually, if you do both @import '../../../tools/tailwind/style.css';
@source '../../../tools'; It should work without creating separate styles all over again. |
Still doesn't seem to work - I've tried using all of these: @import 'tailwindcss';
@import '@repo/tailwind-config/style.css';
@source '../../../tools/tailwind';
@import '../../../tools/tailwind/style.css';
@source '../../../tools';
@import '../node_modules/@repo/tailwind-config/style.css';
@source '../node_modules/@repo/tailwind-config'; Repo is here if you want to have a look: Change '@tailwindcss/vite': 4.0.8 and try looking at the login page. |
Similar to @nktnet1 I've tried several In my (turborepo) monorepo, my tailwind.css file lives in Adding I've also suddenly been unable to load in fonts, which are installed in my |
For more details, see here: tailwindlabs/tailwindcss#16733 (comment)
This document gave me inspiration, and then I tested it and found that it worked fine https://tailwindcss.com/docs/upgrade-guide#using-a-javascript-config-file
I thought it might be that the configuration was not loaded, so I did the following: add @config to the global.css file my global.css
tailwind.config.mjs
Doing so below can also solve the problem
|
This may significantly increase stylesheets size when using libraries. When added via An example would be a react/vue library that ship hundred of components, and an app that use only a few of them.
Can we let this issue open until then ? |
Please work on your QS - this should never have happend in a Patch-Version update. Shortly after migrating to v4 we now have to redesign our project-structure again. We use a common HTML template which includes import of a central tailwind.css config in a central library. Now we have to redesign it, because an unnoticed patch-update broke everything and your solution seems to be "just redesign your project layout over night and inform all your devs, that they have to update and change all their projects again, because the automated security updates will break their projects" |
Hey! I can definitely understand all of your frustrations here and I'm really sorry we had to pull the ripcord on the module-graph approach this way. I'm not sure if you had a chance to look over the PR but that approach we used before was causing a whole lot of reliability issues for many users over a broad variety of different setups. Sometimes these issues were only surfaced in production (as some of them didn't occur in dev mode), which is also an extremely frustrating experience. We ultimately decided to bring the Vite extension closer to our PostCSS extension so that, while it might be a bit more painful to set up initially, at least it runs reliably and predictable across builds. @stafyniaksacha @falco467 I can offer to take a look at both of your project setups if you can share a repro and we can figure out a way to set up the source discovery so that it's not significantly increasing stylesheet sizes or cause you to make changes to your project-structure. |
Hello, @philipp-spiess could we get a link or statement how a monorepo is setup done correctly? So, I configured
with what is the correct setup for 4.0.9? Because "https://tailwindcss.com/docs/installation/framework-guides/nuxt" is not working with 4.0.9 (in my case) |
@skoenfaelt same to me, if use 4.0.7 all works :) |
I think I might have found the best solution for this. If you add
@import "@monorepo/ui-library/tailwind.css";
@source "."; As far as I can tell, the above config successfully scans classes in both FWIW it also feels like a clean solution, IMHO @philipp-spiess, could you chime in? Is this something we could document and rely on going forward, maybe even get covered by a test case or two? |
I tried it in my nuxt project with layers. Does not work well, even if I keep care, that no stylesheets are overwritten by the layer mechanic. For now I will stick to 4.0.7 |
@skoenfaelt regarding:
I've seen many different monorepo setups so if you could briefly sketch your setup (or, even better, provide a repro) I can take a look! In general if it looks something like this:
I link really like @aaronadamsCA's solution: /* packages/ui/src/index.css */
@source "."; /* apps/admin/src/index.css */
@import "tailwindcss";
@import "@monorepo/ui/index.css"; Another approach is that both the /* apps/admin/src/index.css */
@import "tailwindcss";
@source "../../../packages/ui"; |
Okay thanks, my repo also looks like this. |
Tried 4.0.12 and this error still, here the link : |
@CarlosZiegler solution already provided above. |
@nktnet1 here I applied same and still not works if upgrade package > 4.0.7 |
You are sourcing the tailwind package. /* ❌ */
@source '../../../tools/tailwind'; It needs to be the UI package instead in your css file, as noted by philipp-spiess above: /* ✅ */
@source '../../../packages/ui'; |
I could thankfully also solve our problems by using relative paths in all linked tailwind-files. For us it was @philipp-spiess I can absolutely understand why you needed to change the behaviour and I am greatful for you hard work and support. I was just sad that this was a breaking change in a last-digit update, since we apply Patch-Updates automatically without any major checks. |
What version of Tailwind CSS are you using?
v4.0.8
What build tool (or framework if it abstracts the build tool) are you using?
pnpm10.4.1 astro5.3.0 tailwindcss4.0.8 @tailwindcss/vite4.0.8
What version of Node.js are you using?
v20.18.0
What browser are you using?
Chrome
What operating system are you using?
Windows
Reproduction URL
Describe your issue
many styles don't work after upgrading in the Astro project
Especially our private component package cannot parse correctly
Return to 4.0.7 and work normally
The text was updated successfully, but these errors were encountered: