-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix hydration mismatch in production builds when using the Tailwind 4 Integration Guide #4606
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
base: main
Are you sure you want to change the base?
Conversation
|
can you please add some more description about that. what should this point to, a link to the tailwind docs etc. |
|
View your CI Pipeline Execution ↗ for commit 941ac88
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/arktype-adapter
@tanstack/directive-functions-plugin
@tanstack/eslint-plugin-router
@tanstack/history
@tanstack/react-router
@tanstack/react-router-devtools
@tanstack/react-router-with-query
@tanstack/react-start
@tanstack/react-start-client
@tanstack/react-start-plugin
@tanstack/react-start-server
@tanstack/router-cli
@tanstack/router-core
@tanstack/router-devtools
@tanstack/router-devtools-core
@tanstack/router-generator
@tanstack/router-plugin
@tanstack/router-utils
@tanstack/router-vite-plugin
@tanstack/server-functions-plugin
@tanstack/solid-router
@tanstack/solid-router-devtools
@tanstack/solid-start
@tanstack/solid-start-client
@tanstack/solid-start-plugin
@tanstack/solid-start-server
@tanstack/start-client-core
@tanstack/start-plugin-core
@tanstack/start-server-core
@tanstack/start-server-functions-client
@tanstack/start-server-functions-fetcher
@tanstack/start-server-functions-server
@tanstack/valibot-adapter
@tanstack/virtual-file-routes
@tanstack/zod-adapter
commit: |
schiller-manuel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please add some more description about that. what should this point to, a link to the tailwind docs etc.
|
This is also able to be reproduced inside docker builds. Thanks for the tip. More context on the discord thread: https://discord.com/channels/719702312431386674/1431725277758619770 Probably a upstream issue with @tailwindcss or vite plugin |
|
@luksch42 we use tailwind 4 with postcss in the examples and e2e projects of this repo. We stayed clear of the new vite plugin as it didn't seem quite ready yet. The problem described here, is it both hit when using tailwindcss 4 with the vite-plugin and postcss, or it it only one of those that's problematic? |
This issue seems to be occurring: TanStack/router#4959. Applying the teeny fix from this PR TanStack/router#4606 fixes it.
Tailwind CSS v4's `@import` directive needs an explicit `source()` path to ensure consistent CSS asset hashing between client and server builds. Without this, builds can result in the server-rendered page referencing an nonexistent CSS asset, resulting in a 404 (which may manifest in browser devtools as a CORS error). You can see an example here (open devtools to see error): https://69725dbd6dcf150f9fbaeb37--vermillion-brigadeiros-35570b.netlify.app/ (source: https://github.com/serhalp/demo-tanstack-start-20160121). This updates all examples, e2e fixtures, and documentation to use: ``` @import 'tailwindcss' source('../'); ``` Fixes TanStack#4959. Supersedes TanStack#4606. --- Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* test: upgrade TanStack Start fixture to latest RC * test: fix tanstack e2e fixture This issue seems to be occurring: TanStack/router#4959. Applying the teeny fix from this PR TanStack/router#4606 fixes it.
Fix hydration mismatch in production builds when using the Tailwind 4 Integration Guide
Added
source("../")to the Tailwind import to explicitly set the base path for class detection.Problem
Solution
The
source()directive tells Tailwind to always scan from../relative to the CSS file location, regardless of the current working directory during build.What it points to
app/styles/app.css→app/src/)References
Without this explicit path, builds from different working directories (CI/CD, Docker, monorepo tools) will produce inconsistent CSS output.
Mentioned in https://discord.com/channels/719702312431386674/1390062434038845521