From ada17c4ba037356c0f85e5b9fdc37e04febf551e Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Wed, 12 Jul 2023 00:50:01 +0100 Subject: [PATCH] Adjust old sw.js file to remove itself, allowing new service-worker.js to be activated --- static/sw.js | 16 ++++++++++++++++ svelte.config.js | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 static/sw.js diff --git a/static/sw.js b/static/sw.js new file mode 100644 index 0000000..7588cdf --- /dev/null +++ b/static/sw.js @@ -0,0 +1,16 @@ +// Remove the service worker /sw.js from legacy installations +// This should then enable the new /service-worker.js to be installed + +self.addEventListener('activate', function (e) { + console.log(`Unregistering service worker`) + self.registration.unregister() + .then(function () { + return self.clients.matchAll(); + }) + .then(function (clients) { + clients.forEach(client => { + console.log(`Navigating ${client.url}`) + client.navigate(client.url) + }) + }); +}); \ No newline at end of file diff --git a/svelte.config.js b/svelte.config.js index 10e853b..088717c 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,6 +1,6 @@ import adapter from '@sveltejs/adapter-static'; -export default { +const config = { kit: { adapter: adapter({ pages: 'build', @@ -11,3 +11,5 @@ export default { }) } }; + +export default config;