-
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
CSS Modules (Gatsby v2) - New css styles not hot reloading. Requires a page refresh #10316
Comments
If you check your console when this happens, do you see something like the below?
It seems to possibly be related to webpack-contrib/style-loader#320 |
@DSchau sure does!. Happens when you create a new class in a component css file and save. Once you do a manual refresh the error doesn't happen. |
I think it's related to changes introduced in this PR webpack-contrib/style-loader#298 |
I'm facing the same issue. Does anybody know how to resolve the issue? |
As per recent convos in webpack-contrib/style-loader#320, it seems that a full page reload is aways required for CSS Modules when using react hot loader like Gatsby does. I've managed to fix it using the below... The solution is to pass This will mean passing the hmr option to miniCssExtract in In my case, I'm using css modules with the SASS plugin, so it would make sense to make a PR and add the |
Can I get someone to please review my PR? #11032 This is for SASS files, but I'll add another PR for regulare CSS modules once the SASS PR gets through |
PR is merged! thank you very much! |
Description
When adding a new class to a css module, hot reload does not inject the css module class and no styles are shown. Manually refreshing the page will show the new css module class and the correct styles.
Once the page has been manually refreshed after creating a new class, any subsequent changes to the class will hot reload correctly.
Screencast of the issue https://www.useloom.com/share/a1061fb2d4344942af1f9efa4870d965
Note: I've checked gatsby v1 and new css modules display correctly without a page refresh
Steps to reproduce
I can confirm this is an issue using the latest:
Expected result
New css module classes should hot reload and display on the page (after saving) without a manual page refresh
Actual result
No styles show up on the page. A manual page refresh is required
Environment
System:
OS: macOS High Sierra 10.13.6
CPU: (4) x64 Intel(R) Core(TM) i7-4650U CPU @ 1.70GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.11.3 - /usr/local/bin/node
Yarn: 1.12.3 - ~/.yarn/bin/yarn
npm: 4.2.0 - ~/.npm-packages/bin/npm
Browsers:
Chrome: 70.0.3538.110
Firefox: 63.0.3
Safari: 12.0.1
npmPackages:
gatsby: ^2.0.53 => 2.0.63
gatsby-image: ^2.0.20 => 2.0.22
gatsby-plugin-manifest: ^2.0.9 => 2.0.11
gatsby-plugin-offline: ^2.0.16 => 2.0.18
gatsby-plugin-react-helmet: ^3.0.2 => 3.0.4
gatsby-plugin-sharp: ^2.0.14 => 2.0.14
gatsby-source-filesystem: ^2.0.8 => 2.0.10
gatsby-transformer-sharp: ^2.1.8 => 2.1.9
npmGlobalPackages:
gatsby-cli: 2.4.6
The text was updated successfully, but these errors were encountered: