fix offline support for themes
This commit is contained in:
parent
111d6201f3
commit
5f670f6eb3
|
@ -3,9 +3,10 @@ const ASSETS = `cache${timestamp}`
|
||||||
|
|
||||||
// `shell` is an array of all the files generated by webpack,
|
// `shell` is an array of all the files generated by webpack,
|
||||||
// `assets` is an array of everything in the `assets` directory
|
// `assets` is an array of everything in the `assets` directory
|
||||||
const toCache = __shell__.concat(__assets__)
|
const assets = __assets__.map(file => file.startsWith('/') ? file : `/${file}`)
|
||||||
|
const toCache = __shell__.concat(assets)
|
||||||
.filter(filename => !filename.endsWith('.map'))
|
.filter(filename => !filename.endsWith('.map'))
|
||||||
.filter(filename => !filename.startsWith('apple-icon'))
|
.filter(filename => !filename.startsWith('/apple-icon'))
|
||||||
const cached = new Set(toCache)
|
const cached = new Set(toCache)
|
||||||
|
|
||||||
// `routes` is an array of `{ pattern: RegExp }` objects that
|
// `routes` is an array of `{ pattern: RegExp }` objects that
|
||||||
|
@ -48,7 +49,7 @@ self.addEventListener('fetch', event => {
|
||||||
|
|
||||||
event.respondWith((async function () {
|
event.respondWith((async function () {
|
||||||
// always serve assets and webpack-generated files from cache
|
// always serve assets and webpack-generated files from cache
|
||||||
if (cached.has(url.pathname)) {
|
if (url.origin === self.origin && cached.has(url.pathname)) {
|
||||||
return caches.match(req)
|
return caches.match(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue