blaise-io / live-reload

Browser extension for web devs. Monitors source files on a page and reloads page or source file when a change is detected.
MIT License
60 stars 9 forks source link

Is there a way to get this to monitor local source files instead of ones at a URL? #33

Open rubinj30 opened 1 year ago

rubinj30 commented 1 year ago

Hello! I was trying to set this up to monitor my files being changed within a specific directory on my local machine, but the Sources input field is requiring a URL.

Is there a way around this validation and if so, will it work with the local files?

f1rf1n commented 1 year ago

It is not possible for a web extension to read file from your local computer. This is an important safety measure built into browsers. I think this info should be in the readme, but on the official firefox live-reload addon page this is mentioned:

Due to security restrictions in web extensions, files served using the file system (file://...) cannot be monitored. A quick and easy workaround is to serve local files over http using Python, NodeJS or PHP.

These links point to relatively easy ways to 'serve' files from your local machine. I usually like using a virtual server setup to mimic the software and settings of the server where the live site will be hosted. My favorite solution for this is Lando which is an open source solution to make using docker much easier.

In any case when you have set up a way to serve the files to your browser, you can simple point it to something like http://localhost:8080/your.html or https://myproject.lndo.site/ depending on which route you choose.

adynamique commented 1 year ago

i don't know if it's a recent update, but it's possible to give an extension the access to file urls (at least, in ms edge)