-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
🐛 BUG: CSS Module styles do not update upon saving file in development #3654
Comments
Thanks for reporting @Merri! Unfortunately, I couldn't replicate this behavior on my end (either importing CSS modules into jSX or importing CSS modules into |
So far I've been mostly developing on Brave. It does at least have a "shields up" feature in it which I guess could cause issues. I'll try testing tomorrow with that disabled, as well as with other browsers. |
I'm having the same issue on macOS and Chrome |
Interesting! @NapperJLG to confirm, are you seeing this issue when importing CSS modules into Astro files, React / Preact components, or both? |
@bholmesdev Importing CSS modules into React components. I have since given up with it though and converted my React components into Astro ones with |
@NapperJLG Oh no, you shouldn't have to do that! I'll bump the priority on this one, since CSS modules is our recommended React styling solution right now 👍 |
I've encountered a similar issue. I'm using react components ( I've noticed the problem is in the hashed names of the css classes. Here's a very basic example, everything not pertaining to the issue stripped out:
So it seems that during HMR, the hashed class names that get into the <style> tag do not match the class names on the actual rendered components. The problem also occurs simple when reloading the page. Some more info on my setup: Node 16.15.1, running on a headless Ubuntu through Windows' WSL2. Tested out in Brave, Chrome, Firefox. For some reason, the issue in Firefox only occurs ~10% of the time. In Brave and Chrome, it's more like ~75% of the time.
Hope this helps. Let me know if I can help! This is really the only thing holding me back from developing with Astro, otherwise looking forward to using it more. 👍 |
Confirmed this issue definitely happens for non-hydrated JSX components. Unable to reproduce for CSS modules in |
@bholmesdev FYI: You mention that you cannot reproduce it in |
@sHoskens can you provide an example? I feel like we might be talking about several different problems in this issue. |
@bholmesdev which issue have you confirmed? Do you have an example? Here's an example of CSS modules reloading in astro components: https://stackblitz.com/edit/github-zzyewt?file=src/styles/Container.module.css |
Bumping down the importance since we're without a recreation. |
I was able to look into this while working on #3932. AFAICT, this will be fixed by #3932 since we're scaling back our custom HMR handling and using what Vite gives us out of the box. @sHoskens would you mind searching for other |
Sure thing, I'll look into this as soon as I'm able. My astro project is temporarily on hold, but I'll test out a few different approaches and, if I still encounter these issues, provide you with examples. |
Same issue, seems to only happen for imports:
CSS edits in the |
What version of
astro
are you using?1.0.0-beta.47
Are you using an SSR adapter? If so, which one?
Vercel
What package manager are you using?
yarn
What operating system are you using?
Windows
Describe the Bug
When changing and saving CSS Module file the style change does not get reflected to current open page in development. This can be so bad that the only way to get the styles to latest changes is to restart the local dev server.
Additionally at least on Vercel SSR adapter the CSS Modules seem not to work at all:
To replicate issue
The changes may only get updated when something else is changed, such as edit some other aspect of the page, visit another page, restart dev, or in the case of CodeSandbox an auto-refresh (not caused by editing the CSS module file) updates the page.
Expected behavior
Changed style is reflected on the page.
Link to Minimal Reproducible Example
https://codesandbox.io/s/cool-mahavira-0dkrgc?file=/src/pages/index.astro
Participation
The text was updated successfully, but these errors were encountered: