Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

When building sapper with basepath, files and shell of service-worker does not include basepath #1538

Open
@floratmin

Description

@floratmin

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions