I’ve installed Sage for the second time now (first use of the theme) and I just can’t make BrowserSync notice any PHP files. My config.json looks like this:
I’m working on a Windows machine, Apache, php and mysql being handled by Ampps. I honestly don’t understand why the “publicPath” is “/wp-content/themes/theme-name” but I’ve seen this config online and this is the only variable that doesn’t make js saves loop reload for ever.
For everyone having these or similar issues with browsersync and/or yarn not building/syncing Scss and Php Files, I would recommend this troubleshooting guide by @knowler:
Hmm that’s a good tip (however a bit worrisome because I like using different devices and browsers at once some times). But I did test having only one tab open.
By “using proxy” I meant using proxyUrl localhost:3000. In fact, what loads on the browser is always “localhost:3000/mysite”, no matter if I use ...:3000 or ...:3000/mysite at proxyUrl.
Did you move or migrate your site? That sounds like a wrong site URL in the wordpress database …
I think having 3-4 tabs of :3000 open at a time might work aswell depending on your computer performance - especially, if they are opened on different devices, as browsersync is working client-side, not server-side I guess. Maybe the problem with webpack/browsersync is, that it is monitoring and compiling various files in the theme-directory, which can be quite much. If it then has to refresh multiple tabs on the same machine at a time and you might also have other software running in the background (e.g. adobe PS or Illu), that might result in memory overload.
Not really… fresh installation. It does sound like a URL mismatch, I agree. But I’m not aware of where is that mismatch happening. Also, why would scss and js work just fine and not php?
The one thing of note in the console is that it’s calling for a inexistent css file in a “dist” folder, which is weird. But the css is working fine!
If you are viewing the site on localhost:3000 the /dist-folder is not important, it is for the production-assets, which you produce with yarn build:production to be published to a remote server.
I don’t think that has anything to do with your problem.
But I think your devUrl and ProxyUrl in the config.json are wrong. They should be something like this:
“devUrl”: “example.test”,
“proxyUrl”: “http://localhost:3000”,
But don’t know if this is the reason why your php isn’t working.
publicPath looks good so far. its the relative path from the site folder to your theme folder.
I thought maybe something similar is causing your problem as well? Maybe your php-files aren’t correctly referenced or you edited the functions.php or some other major .php file, which now affects your problems?
And have you tried deleting the .cache-loader folder and manually refreshing your site then?