4 ms·
I use createPages and I get hot reloading when running gatsby develop. I also just figured out how to trigger hot reloading for sources that normally don’t tri
by ricksharp 6y ago
I use createPages and I get hot reloading when running gatsby develop.
I also just figured out how to trigger hot reloading for sources that normally don’t trigger it (markdown files which I was manually processing).
Basically, I discovered that gatsby will hot-reload when it sees a change in code files (.tsx). So I created an essentially empty _rebuild-trigger.tsx file and imported that in my main page template.
Now, to change the page content and trigger a hot-reload:
- I have an observable subscribed in createPagesStateful that calls deletePage and createPage
- Then write to the file _rebuild-trigger.tsx file
I need to make a blog post because it works great (and I could tie it to any change source - like file system watcher - during development).
- taphangum 6y agoPlease do share!
- ricksharp 6y agoThis commit has the important pieces. Look for the createPage call and rebuild-trigger. I’ll try to put together a blog post when I can. https://github.com/ricklove/rick-love-master/commit/8eebd4f90b7b9a14729ea979c1e3dad1591cd303 https://github.com/ricklove/rick-love-master/commit/8eebd4f9...
- taphangum 6y agoThis looks very promising. I've given it a like, will take a deeper look when I get on the laptop. :) Thanks a lot for sharing Rick!
- tomduncalf 6y agoHmmm, I seem to recall that hot reload didn’t reload the content, but I’ll check again! In any case it’s not as smooth for allowing content editors to preview content as NextJS’s preview unless I’ve missed something - with Next it will reload the content on every page load if you have the preview cookie set