Closed theskillwithin closed 4 years ago
I can reliably repro this. It is recompiling every time, but isn't doing HMR.
I should add that I am getting the same error when editing the JSX file too, not just the styles.
OK, I think I've solved it. The problem is that you're importing the JSX and styles for the about component like this:
import AboutPageContent from '~/components/about'
import Newsletter from '~/components/Newsletter'
import { AboutAngledBG } from '~/components/about/styles'
However the folder name isn't about/index.js
, it's About/index.js
. Because your filesystem is case-insensitive it compiles fine, but it means that when webpack sees the changed file, it doesn't recognise that it's a dependency. Changing the import to this fixes it for me:
import AboutPageContent from '~/components/About'
import Newsletter from '~/components/Newsletter'
import { AboutAngledBG } from '~/components/About/styles'
I'm going to close this as it's fixed for me. If it's still broken for you then please reopen and let me know.
Description
When working on gatsby project seems like all the sudden in the past few months hot reloading / build has serious intermittent problems. especially noticeable on project with styled components ( emotionjs ). can take 1-10+ times hitting save without hot reloading working and even upon waiting a long time or refreshing the browser still not updated. I thought was similar to issue #26192 but I'm not getting the same error so is a different issue.
occurs on all browsers
have been reading into issues, and deep diving into why this might be happening for awhile now so I really appreciate your help <3
Steps to reproduce
git clone repo (simplified cloned repo) : https://github.com/theskillwithin/gatsby-hot-reloading-styled-components
npm i
npm start
start editing components and styles and sometimes hot reloading fails. ie: go to
src/components/About/styles.js
and edit the styles in line 25 (export const Center = styled.div``)remove styles from this and no change appears to occur in hot reloading intermittently
Expected result
rebuild and hot reloading works
Actual result
rebuild seems to occur successful in terminal, and even --verbose seems to show no errors. however sometimes to a very painful extent does not work. even upon refreshing browser. even waiting 10 seconds between saves does not help. end up having to restart build to get to work
Environment