-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Remix + Tailwind on hmr update and reload the CSS breaks #15516
Comments
I found that when I manually edit the Something interesting: I run the I personally think it is not a Vite bug, because in other projects Vite is OK to update CSS files that are changed. I think it is a Remix plugin bug. |
Your issue could be due to the unintended usage of tailwind on (Remix) Vite. For some time (since non Vite version), Remix supports tailwind/postcss out-of-the-box, so I don't think you need dedicated I updated your repro to illustrate this. Would this work for you? https://stackblitz.com/edit/github-4n9xrs?file=app%2Froutes%2F_index.tsx //// in app/routes/_index.ts
// import "../../src/output.css";
import '../../styles.css'; Here are few references from their documentation:
(Btw, Remix Vite is still labelled as "unstable", so it might be better to report the issue there first for visibility of Remix's maintainer. I think it's more likely for people there to help the issue than people here) |
I couldn't reproduce the issue with the repro given. It seems to always update fine for me. If you could slim down the issue to a plain Vite project, we could probably look deeper if it's a Vite issue. Otherwise it might be a Remix issue. |
Your suggestion doesn't work. Please try it locally and you will see what I mean; Also I was able to find the issue. I have noticed that I get hydration issues both in Firefox and Chrome browsers. And in this two browsers, the issue with the HMR and styles remain. I decided to update However this isn't ideal since I am working on a larger scale project. So it seems like this isn't ready yet. Also, your reproduction fork isn't something that produces trusty results because the serving and rendering is being done by stackblitz. |
Regarding hydration error, there are a few known issues tracked on Remix. Though you might have already discovered about React 18.3, I'll reference this issue and comment by Remix team remix-run/remix#4822 (comment) so that Vite team can also know potentially relevant context. |
Yes I am well aware of that by now. I have spent the last couple of hours reading all the issues both in React and Remix communities. Like I said, the canary version seems to work fine by me. |
I think this is a React / Remix issue (which has been reproduced pre-Vite era of Remix), so let me close this. |
Describe the bug
When adding/editing a css property with tailwind classes,
OR
When adding, removing or chaning a JSX element,
Vite HMR detects the change , and the page becomes stripped of css. So we basically loose all our styles.
I was having this issue in my companies project, but I could easily reproduce it in a new project.
Reproduction
https://github.com/Danones/remix-vite-tailwind-repro
Steps to reproduce
Open the reproduction project.
Get the project running by using the following command
npm run dev
;Get Tailwind running in watch mode:
npx tailwindcss -i ./styles.css -o ./src/output.css --watch
Open the Browser on http://localhost:5173/ and make sure all styles are ok.
Check the content of the
_index.tsx
file. You will notice that there is some JSX commented out in line 41{/* <p className="text-5xl bg-red-200 font-bold ">Test</p> */}
Uncomment , and save.
If you check the UI, should be now stripped from CSS.
Momentarily I was able to get it working when I initially created the project, but when I restarted the server I could never get it working anymore.
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: