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",