When building sapper with basepath, files and shell of service-worker does not include basepath
Opened this issue · 1 comments
When i add a basepath to the application with:
in server.js:
polka()
.use(
'/subpage',
...
and call sapper export --basepath subpage
then this basepath is not appended to the list of files and shell generated in the service-worker.js, which makes the service-worker fail.
Sapper generates in service-worker.js:
const files = [
"/service-worker-index.html",
"/favicon.png",
"/global.css",
"/logo-192.png",
"/logo-512.png",
"/manifest.json",
"/successkid.jpg"
];
const shell = [
"/client/client.b97dd9ad.js",
"/client/index.98d8c2bb.js",
"/client/about.fb76b696.js",
"/client/index.2e89984a.js",
"/client/[slug].6afd8c3d.js"
];
It should actually be:
const files = [
"/subpage/service-worker-index.html",
"/subpage/favicon.png",
"/subpage/global.css",
"/subpage/logo-192.png",
"/subpage/logo-512.png",
"/subpage/manifest.json",
"/subpage/successkid.jpg"
];
const shell = [
"/subpage/client/client.9cf6791c.js",
"/subpage/client/index.8b5a8666.js",
"/subpage/client/about.c06fa789.js",
"/subpage/client/index.69e28be9.js",
"/subpage/client/[slug].0552c7c2.js"
];
Tested with a clean install and version 0.28.7
After further investigating the problem, i realized that this bug is related to the static folder. When creating sub folders in the static folder for each page, then all files with respective folder structure get added to each service-worker. The sapper --static
flag should be considered when precached files are injected into the service-workers. I set up an example repository at https://github.com/floratmin/sapper-subpage-example.