-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
fix(core): Disable HMR for CSS modules #11032
Conversation
This is modifying the sass rules? I assume you meant to modify all of the CSS module rules? |
@KyleAMathews I'm only modifying the SASS CSS modules (eg If we want to add this fix for regular CSS modules (no SASS), then shouldn't that fix go into the main Gatsby package? (maybe |
@jonlow sorry for keeping you waiting, i'll be checking this today! It would be really helpful if you do it for all cssmodules plugins like less, ... |
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.
I've tested this change and looks Great! I've also added hmr: false to all our flavors of cssmodules.
@jonlow 🥇 Thank you very much for taking this issue on! And We're really sorry that it took so long to actually look at this one.
Holy buckets, @jonlow — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! |
Description
CSS modules will not work correctly with style-loader when HMR is enabled (HMR was introduced in gatsby v2). For new styles to appear on a page, a full page refresh is required for css modules to work. Otherwise, an error is thrown. This PR disables HMR for css-modules as suggested by webpack-contrib/style-loader#320 so that saving a
.module.scss
file will refresh the page and show any new styles.Here's a screencast showing the issue before the fix https://www.useloom.com/share/a1061fb2d4344942af1f9efa4870d965
Related Issues
#10316