Search code examples
livereload

Use Livereload when local server is run from a virtual machine?


Im using Virtualbox on my PC to run Ubuntu which is my local development environment. The web browsers that im using the view the site are run from Windows.

How can I set up Livereload? If I install Livereload in Ubuntu then it cant reload my web browsers in Windows. If I install Livereload in Windows then I cant find the files for it to watch as they are not part of the normal file system.


Solution

  • Potential quick solution: just use my adhoc web server. Two of its features are:

    1. Simple to install/use
    2. LiveReload built-in

    (note: only these file extensions are monitored: htm, html, css, js, json, png, gif, php, php5, py, rb, erb. Other file types can be monitored, but that will require modification to adhoc.)


    Otherwise, your question needs more info:

    • How are you serving your web pages?
    • What have you done to get LiveReload to work?
    • Are your getting any error messages?

    Some info to help you start using LiveReload:

    LiveReload needs two components. Make sure you satisfy all the requirements:

    1. A LiveReload server. The server sends notifications to clients whenever changes are made to the files on the server (over a web socket). Note this server is not necessarily the web server.
    2. A LiveReload client. The client opens a connection to a LiveReload server. When it receives notifications from the server, it reloads or modifies the page as appropriate. Usually the client is simply a web browser that loads a special livereload.js JavaScript file. This JavaScript file can be manually added to the HTML file or "injected" by the web server. Adhoc automatically injects the script for you. There are web browser extensions that will also inject the script for you.