From 3e0abe329f7e0fe1484af733388c8d1d575d4953 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 25 Dec 2022 09:19:26 +0100 Subject: [PATCH] Fixed preview generation, including service worker --- .github/workflows/deploy-preview.yml | 1 - src/service-worker.ts | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml index 019913fe..43cc780a 100644 --- a/.github/workflows/deploy-preview.yml +++ b/.github/workflows/deploy-preview.yml @@ -21,7 +21,6 @@ jobs: run: | npm ci --force && \ node ./scripts/set-homepage.js /shlink-web-client/${GITHUB_HEAD_REF#refs/heads/} && \ - rm src/service-worker.ts && \ npm run build - name: Deploy preview uses: shlinkio/deploy-preview-action@v1.0.1 diff --git a/src/service-worker.ts b/src/service-worker.ts index 0a2dc7cb..6adaa184 100644 --- a/src/service-worker.ts +++ b/src/service-worker.ts @@ -12,6 +12,7 @@ import { ExpirationPlugin } from 'workbox-expiration'; import { precacheAndRoute, createHandlerBoundToURL } from 'workbox-precaching'; import { registerRoute } from 'workbox-routing'; import { StaleWhileRevalidate } from 'workbox-strategies'; +import pack from '../package.json'; declare const self: ServiceWorkerGlobalScope; @@ -49,7 +50,7 @@ registerRoute( // Return true to signal that we want to use the handler. return true; }, - createHandlerBoundToURL('/index.html') // TODO Add prefix + createHandlerBoundToURL(`${pack.homepage}/index.html`) ); // An example runtime caching route for requests that aren't handled by the