-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathsw.js
31 lines (25 loc) · 897 Bytes
/
sw.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function clientRootUrl() {
return self.location.href.replace("sw.js","");
}
function env() {
return (self.location.hostname === "vitemadose.covidtracker.fr")?'prod':'dev';
}
self.addEventListener('install', function(event) {
console.log('Service Worker activating...');
// event.waitUntil(self.skipWaiting()); // Activate worker immediately
});
self.addEventListener('activate', function(event) {
console.log('Service Worker activating...');
event.waitUntil(
Promise.all([
Promise.resolve()
]).then(function() {
console.log('SW activation finished !');
return self.clients.claim();
})
);
});
// Dummy fetch handler to make PWA installable (without this, we won't have the installation CTA on the website)
self.addEventListener('fetch', function(event) {
//console.log("in dummy fetch handler");
});