Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@wKovacs64
Copy link
Owner

@wKovacs64 wKovacs64 commented Jun 20, 2025

For reasons I don't fully understand, Vite + Tailwind v4 generates two different CSS files in production builds, one for the client and one for the server - with different hashes in the name. This causes React hydration issues in production. Leveraging Vite's CSS side-effect imports rather than the traditional React Router "links" method resolves the issue. ¯\_(ツ)_/¯ Whatever.

@wKovacs64 wKovacs64 requested a review from Copilot June 20, 2025 02:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses Tailwind CSS v4 hydration issues by updating how CSS is imported in the root component.

  • Changed the CSS import from using a URL query parameter to a direct import.
  • Removed the stylesheet link reference that pointed to the appStylesUrl variable.
Comments suppressed due to low confidence (2)

app/root.tsx:5

  • Replacing the URL-based import with a direct CSS import can affect how the CSS file is processed by the build tool. Confirm that this change aligns with your bundler configuration to ensure correct injection and ordering of styles for hydration.
import '~/styles/app.css';

app/root.tsx:26

  • Since the CSS is now imported directly, the removal of the stylesheet link in the links array is appropriate if the bundler correctly injects the styles. Verify that this change does not inadvertently omit the stylesheet in the final HTML output.
  },

@wKovacs64 wKovacs64 merged commit 4cfc9f1 into dev Jun 20, 2025
6 checks passed
@wKovacs64 wKovacs64 deleted the fix-css branch June 20, 2025 02:23
@wKovacs64
Copy link
Owner Author

🎉 This PR is included in version 3.5.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants