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
- Rebuilds the destination directory upon running
grunt workbox-buildon the
public/folder (to create a “precache manifest” of all the files for the script it’ll render).
- Renders resulting
sw.jsfile on the same
public/folder. Just at the root (i.e.
Running it on Github Pages causes no problems. All files are detected. No 404s.
But when I run it with
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?