From 722f1c806c7b50b50570afca385dbe0c607f884c Mon Sep 17 00:00:00 2001 From: Jake Archibald Date: Wed, 9 Dec 2020 21:54:08 +0000 Subject: [PATCH] Correct service worker name --- rollup.config.js | 4 +++- src/copy/sw.js | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/copy/sw.js diff --git a/rollup.config.js b/rollup.config.js index a16d32bd..9d5026a0 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -112,7 +112,9 @@ export default async function ({ watch }) { plugins: [ { resolveFileUrl, resolveImportMeta }, OMT({ loader: await omtLoaderPromise }), - serviceWorkerPlugin({ output: 'static/sw.js' }), + serviceWorkerPlugin({ + output: 'static/serviceworker.js', + }), ...commonPlugins(), commonjs(), resolve(), diff --git a/src/copy/sw.js b/src/copy/sw.js new file mode 100644 index 00000000..b5767ccf --- /dev/null +++ b/src/copy/sw.js @@ -0,0 +1,14 @@ +// I accidentally shipped with the wrong service worker name. +// This picks up users that still might be using that version. +// We'll be able to delete this file eventually. + +addEventListener('install', () => { + skipWaiting(); +}); +addEventListener('activate', async () => { + await self.registration.unregister(); + const allClients = await clients.matchAll({ + includeUncontrolled: true, + }); + for (const client of allClients) client.navigate('/'); +});