#Is it possible to watch files in the public directory for changes during dev (not build)?

1 messages · Page 1 of 1 (latest)

fading lantern
#

I am using https://github.com/ourcade/phaser3-vite-template with JS, not TS, and I have a bunch of .png and .json files in /public/assets. I would like vite to hot-reload the site when I update any of the files in my public directory.

I've tried the stuff I could find on this online - server.watch options and custom plugins; none of it seems to work for me. The closest I got was a StackBlitz from someone, which stopped working when I forked it (from here: https://stackoverflow.com/questions/69626090/how-to-watch-public-directory-in-vite-project-for-hot-reload). I was not able to get this working for my case.

A minimal reproduce is here: https://stackblitz.com/edit/vitejs-vite-oksfp2?file=public%2Fassets%2Fvite.svg. Change something in the svg file, like the first number in the viewBox value to 100 instead of 0 and save the file. I would like the page to reload when that happens, but it doesn't. Manually reloading shows the altered file (the left side of the vite logo is cut off now).

Can you perhaps help?

fading lantern
#

I did some more research, and server.watch option can apparently only narrow down the list of watched files, not add anything, so that approach is right out.

I found a bunch of discussions on HMR for dist when stuff changes in public, but that's not my situation. I don't need HMR, a full reload on file change would be quite enough.