Skip to content

Commit

Permalink
Ensure the app reloads on SW change
Browse files Browse the repository at this point in the history
  • Loading branch information
theninthsky committed Nov 25, 2022
1 parent 1bd99fe commit 6637c83
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion public/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
self.addEventListener('install', async () => {
self.skipWaiting()
await Promise.all(self.__WB_MANIFEST.map(({ url }) => fetch(url)))

const asyncScripts = self.__WB_MANIFEST.filter(script => !/scripts\/(main|runtime)\./.test(script))

await Promise.all(asyncScripts.map(({ url }) => fetch(url)))

const [window] = await self.clients.matchAll({ type: 'window' })

Expand Down
2 changes: 1 addition & 1 deletion src/pages-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
{
"chunk": "core-web-vitals",
"path": "/web-vitals",
"title": "Web Vitals",
"title": "Core Web Vitals",
"description": "This page specifies the values of core web vitals."
}
]
1 change: 0 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ module.exports = (_, { mode }) => {
? [
new InjectManifest({
include: [/scripts\/.+\.js$/],
exclude: [/scripts\/main\./, /scripts\/runtime\./],
swSrc: path.join(__dirname, 'public', 'service-worker.js')
})
]
Expand Down

0 comments on commit 6637c83

Please sign in to comment.