[Vuejs]-Implementing Live Reloading for WordPress and Vue Development on Localhost

0👍

Using a proxy like this does work – but it causes everything to be proxied which is a bit extreme if all you want is live-reloading.

Browsersync has ‘snippet mode’ + ‘localOnly’ for this.

For example, you can run

browser-sync start --files 'app/**/*.php' --localOnly

Which will output the following in your terminal

$ browser-sync start --files 'app/**/*.php' --localOnly
[Browsersync] Copy the following snippet into your website, just before the closing </body> tag
<script async id="__bs_script__" src="http://localhost:3000/browser-sync/browser-sync-client.js?v=2.29.2"></script>

So, copy the HTML snippet into any PHP template or HTML file and you’ll get live-reloading etc

https://gist.github.com/shakyShane/d2d12070b1c9b6c56e7ef3403e872de7

Leave a comment