forked from RustedLessPass/RustedLessPass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice_worker.js
71 lines (67 loc) · 2.4 KB
/
service_worker.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
var cacheName = "rustedlesspass";
var filesToCache = [
"./",
"index.html",
"manifest.json",
"service_worker.js",
"index.css",
"pico.orange.min.css",
"rustedlesspass-web.js",
"rustedlesspass-web_bg.wasm",
];
// Add all files in the "assets" directory
var assetsFiles = [
"./assets/fontawesome/css/all.css",
"./assets/fontawesome/css/all.min.css",
"./assets/fontawesome/css/brands.css",
"./assets/fontawesome/css/brands.min.css",
"./assets/fontawesome/css/fontawesome.css",
"./assets/fontawesome/css/fontawesome.min.css",
"./assets/fontawesome/css/regular.css",
"./assets/fontawesome/css/regular.min.css",
"./assets/fontawesome/css/solid.css",
"./assets/fontawesome/css/solid.min.css",
"./assets/fontawesome/css/svg-with-js.css",
"./assets/fontawesome/css/svg-with-js.min.css",
"./assets/fontawesome/css/v4-font-face.css",
"./assets/fontawesome/css/v4-font-face.min.css",
"./assets/fontawesome/css/v4-shims.css",
"./assets/fontawesome/css/v4-shims.min.css",
"./assets/fontawesome/css/v5-font-face.css",
"./assets/fontawesome/css/v5-font-face.min.css",
"./assets/fontawesome/webfonts/fa-brands-400.ttf",
"./assets/fontawesome/webfonts/fa-brands-400.woff2",
"./assets/fontawesome/webfonts/fa-regular-400.ttf",
"./assets/fontawesome/webfonts/fa-regular-400.woff2",
"./assets/fontawesome/webfonts/fa-solid-900.ttf",
"./assets/fontawesome/webfonts/fa-solid-900.woff2",
"./assets/fontawesome/webfonts/fa-v4compatibility.ttf",
"./assets/fontawesome/webfonts/fa-v4compatibility.woff2",
"./assets/icons/maskable_icon_x48.png",
"./assets/icons/maskable_icon_x96.png",
"./assets/icons/maskable_icon_x128.png",
"./assets/icons/maskable_icon_x192.png",
"./assets/icons/maskable_icon_x384.png",
"./assets/icons/maskable_icon_x512.png",
"./assets/icons/maskable_icon_x512.icns",
"./assets/icons/maskable_icon_x512.ico",
"./assets/minimal-theme-switcher.js",
"./assets/pico.orange.min.css",
];
filesToCache.push(...assetsFiles);
/* Start the service worker and cache all of the app's content */
self.addEventListener("install", function (e) {
e.waitUntil(
caches.open(cacheName).then(function (cache) {
return cache.addAll(filesToCache);
})
);
});
/* Serve cached content when offline */
self.addEventListener("fetch", function (e) {
e.respondWith(
caches.match(e.request).then(function (response) {
return response || fetch(e.request);
})
);
});