ServiceWorker: skipWaiting and reload tabs when new ServiceWorker is ready
This commit is contained in:
parent
66399f754e
commit
174496c71d
2 changed files with 10 additions and 1 deletions
|
@ -31,7 +31,15 @@ function main() {
|
||||||
|
|
||||||
if (BuildConfig.NODE_ENV === 'production') {
|
if (BuildConfig.NODE_ENV === 'production') {
|
||||||
// avoid offline in dev mode because it's harder to debug
|
// avoid offline in dev mode because it's harder to debug
|
||||||
OfflinePluginRuntime.install();
|
// https://github.com/NekR/offline-plugin/pull/201#issuecomment-285133572
|
||||||
|
OfflinePluginRuntime.install({
|
||||||
|
onUpdateReady: function() {
|
||||||
|
OfflinePluginRuntime.applyUpdate();
|
||||||
|
},
|
||||||
|
onUpdated: function() {
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
perf.stop('main()');
|
perf.stop('main()');
|
||||||
});
|
});
|
||||||
|
|
|
@ -85,6 +85,7 @@ module.exports = merge(sharedConfig, {
|
||||||
ServiceWorker: {
|
ServiceWorker: {
|
||||||
cacheName: 'soapbox',
|
cacheName: 'soapbox',
|
||||||
entry: join(__dirname, '../app/soapbox/service_worker/entry.ts'),
|
entry: join(__dirname, '../app/soapbox/service_worker/entry.ts'),
|
||||||
|
events: true,
|
||||||
minify: true,
|
minify: true,
|
||||||
},
|
},
|
||||||
cacheMaps: [{
|
cacheMaps: [{
|
||||||
|
|
Loading…
Reference in a new issue