From 606c645dd9a883c4e3c0a64cb92d56a1445d8341 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Wed, 14 Oct 2020 13:19:00 +0200 Subject: Fix gh-pages path problem with service-worker --- package.json | 2 +- src/service-worker.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f56e50a..b1f5e1c 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "build": "npm run build:css && sapper build --legacy", "watch:css": "postcss static/global.css -o static/index.css -w", "build:css": "NODE_ENV=production postcss static/global.css -o static/index.css", - "export": "sapper export --basepath Aurora-data --legacy", + "export": "sapper export --basepath 'Aurora-data' --legacy", "start": "node __sapper__/build", "start:dev": "sapper dev", "cy:run": "cypress run", diff --git a/src/service-worker.ts b/src/service-worker.ts index 1441676..b721b18 100644 --- a/src/service-worker.ts +++ b/src/service-worker.ts @@ -2,9 +2,13 @@ import { timestamp, files, shell, routes } from '@sapper/service-worker'; const ASSETS = `cache${timestamp}`; + +const nonRootFiles = files.map(f => "/Aurora-data" + f); +const nonRootShell = shell.map(f => "/Aurora-data" + f); + // `shell` is an array of all the files generated by the bundler, // `files` is an array of everything in the `static` directory -const to_cache = (shell as string[]).concat(files as string[]); +const to_cache = nonRootShell.concat(nonRootFiles); const cached = new Set(to_cache); self.addEventListener('install', (event: EventType) => { -- cgit v1.2.3