From c661f0cf5fd9f1c4554e87e91a1e145a3d89c314 Mon Sep 17 00:00:00 2001 From: adueck Date: Wed, 14 Aug 2024 20:04:48 -0400 Subject: [PATCH] try again with sw --- website/public/service-worker.js | 16 ++++++++++++++++ website/vite.config.ts | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 website/public/service-worker.js diff --git a/website/public/service-worker.js b/website/public/service-worker.js new file mode 100644 index 0000000..8502832 --- /dev/null +++ b/website/public/service-worker.js @@ -0,0 +1,16 @@ +// https://github.com/NekR/self-destroying-sw + +self.addEventListener("install", function (e) { + self.skipWaiting(); +}); + +self.addEventListener("activate", function (e) { + self.registration + .unregister() + .then(function () { + return self.clients.matchAll(); + }) + .then(function (clients) { + clients.forEach((client) => client.navigate(client.url)); + }); +}); diff --git a/website/vite.config.ts b/website/vite.config.ts index f9c1cc4..a4c6944 100644 --- a/website/vite.config.ts +++ b/website/vite.config.ts @@ -14,7 +14,7 @@ export default defineConfig({ cleanupOutdatedCaches: true, }, includeAssets: ["**/*.(js|html|svg|png|jpg|jpeg|eot|woff|woff2|ttf)"], - filename: "service-worker.js", + filename: "sw.js", manifest: { short_name: "Pashto Dictionary", name: "LingDocs Pashto Dictionary",