Sage never injects changes on save. I always need to save the file I’m editing, then manually refresh the browser to see changes. I have my domain “parked” by Laravel Valet at https://bedrock.test, and everything seems to work as expected except for HMR.
Running yarn build compiles styles and scripts and the changes are visible after a full page refresh. If I run this after every change I make, I can see the styles changing after a full refresh. Running yarn dev compiles styles as well, and I only have to run it once, but I still need to manually refresh the browser to see the changes.
So essentially, I can’t get HMR working. I’ve been stuck on this a while as I try to figure out my workflow with Sage/Bedrock/Valet.
Here’s part of my bud.config.js which may be the problem:
Note that, again, I’m accessing my local site at bedrock.test and not https://localhost:3000. When I visit localhost:3000, I get “Safari can’t open page”. I figured I should be seeing the changes on the proxy URL I specified.
Thank you for any help you can provide. I’m struggling to find documentation and resources that address this. Since this I’m working with a clean install of Sage / Bedrock, I feel I’m missing something basic here.
I’ve also tried installing the latest development version of Sage and switching to that new theme to see if that makes a difference - it did not. I’m still experiencing the same issue of styles not being injected.
At this point should I give up on using Laravel Valet and give Trellis a shot? I thought this set up would be fast and straight-forward but I’m struggling here
Thanks for the response, Tom. That’s great to hear you’ve got valet sites running fine, because I do want to get this method working.
I did another fresh install with bedrock to see if that would make a difference, and made the changes you suggested. Using both Chrome and Safari with caches and cleared (and also incognito mode and restarted computer for good measure) http://localhost:3000 simply redirects to what I’ve renamed https://roots.test (with SSL despite my attempts to view the site as http).
Looks like you’re almost there! The redirect you’re experiencing now is coming from Valet.
Because your Valet site is secured, your upstream configuration needs to be HTTPS. Otherwise you’ll be redirected outside of the HMR server by Valet / Nginx. For example:
You’re right, I’m so close now. Changing those settings did work did stop the redirection. I appreciate the explanation.
I’m now able to visit http://localhost:3000/ and every change I make to styling triggers the appearance of a glowing blue circle in the lower-left corner of the screen. That must be HMR at work!
One last problem is that the styles still aren’t being injected, which looks to be a CORS issue: