Hi,
I’m running gulp workbox-build
alongside Hugo. I use it to generate a service worker.
I basically follow this tutorial (https://andeers.com/2019/07/service-worker-refresh/).
What it does:
- Cleans the
public/
directory. - Rebuilds the destination directory upon running
hugo
. - Runs
grunt workbox-build
on thepublic/
folder (to create a “precache manifest” of all the files for the script it’ll render). - Renders resulting
sw.js
file on the samepublic/
folder. Just at the root (i.e../sw.js
).
Running it on Github Pages causes no problems. All files are detected. No 404s.
But when I run it with hugo serve
, sw.js
isn’t detected and returns a 404 in the console.
I also find that this is true for all files manually added to the public/
folder after running hugo
. (Example: I manually add new-file.txt
to the public/
folder and reference it in a template partial. This forces a live reload. new-file.txt
is still 404 on the localhost.)
This also comes after I check the path references multiple times and verify that they are correct.
Is there any workaround here so that any file in the manually added to the public/
folder after hugo
will not return a 404 in the localhost?
Thanks!