summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package.json6
-rw-r--r--public/sw.js65
-rw-r--r--src/sw.js57
3 files changed, 73 insertions, 55 deletions
diff --git a/package.json b/package.json
index 5564bd39..395a572e 100644
--- a/package.json
+++ b/package.json
@@ -8,8 +8,10 @@
"watch:css": "postcss src/css/* --dir public/css --watch",
"build:js": "babel src/js/* --out-dir public/js",
"watch:js": "babel src/js/* --out-dir public/js --watch",
- "build": "yarn build:css & yarn build:js",
- "watch": "yarn watch:css & yarn watch:js",
+ "build:sw": "babel src/sw.js --out-dir public/",
+ "watch:sw": "babel src/sw.js --out-dir public/ --watch",
+ "build": "yarn build:css & yarn build:js & yarn build:sw",
+ "watch": "yarn watch:css & yarn watch:js & yarn watch:sw",
"dev": "./launch.sh",
"check": "./launch.sh check"
},
diff --git a/public/sw.js b/public/sw.js
index e26fd6cc..3de310ae 100644
--- a/public/sw.js
+++ b/public/sw.js
@@ -1,55 +1,14 @@
-const cacheName = 'cache-v1'
-const resourceToPrecache = [
- '/',
- '/index.html',
- '/404.html',
- '/css/style.css',
- '/css/404.css',
- '/css/index.css',
- '/css/ghrepo.css',
- '/css/about.css',
- '/css/devicon.min.css',
- '/js/main.js',
- '/js/about.js',
- '/js/dynamicBlob.js',
- '/js/getrepo.js',
- '/js/hacktype.js',
- '/js/header.js',
- '/js/index.js',
- '/js/mouseblob.js',
- '/js/randomblob.js',
- '/js/rbg.js',
- '/js/tilt.conf.js',
- '/js/tilt.conf.noglare.js',
- '/js/tilt.js',
- '/js/2dtilt.js',
- '/fonts/Hacked-KerX.ttf',
- '/fonts/SmoothElegantRegular-ZLv3.ttf',
- '/fonts/LigaJetBrainsMonoNerdFont-Regular.ttf',
- '/fonts/Big500-8MLOM.ttf',
- '/fonts/Monoton.ttf',
- '/fonts/RockSalt-Regular.ttf',
- '/fonts/audiowide.ttf'
- // '/css/',
- // '/js/',
- // '/pages/',
- // '/fonts/'
-]
+"use strict";
-self.addEventListener('install', event => {
- console.log("Service Worker: Installed");
- event.waitUntil(
- caches.open(cacheName)
- .then(cache => {
- return cache.addAll(resourceToPrecache)
- })
- )
-})
-
-self.addEventListener('fetch', event => {
- event.respondWith(caches.match(event.request)
- .then(cachedResponse => {
- return cachedResponse || fetch(event.request);
- })
- );
+var cacheName = 'cache-v1';
+var resourceToPrecache = ['/', '/index.html', '/404.html', '/pages/info/about.html', '/pages/repo/github/repos.html', '/css/style.css', '/css/404.css', '/css/index.css', '/css/ghrepo.css', '/css/about.css', '/css/devicon.min.css', '/js/main.js', '/js/about.js', '/js/dynamicBlob.js', '/js/getrepo.js', '/js/hacktype.js', '/js/header.js', '/js/index.js', '/js/mouseblob.js', '/js/randomblob.js', '/js/rbg.js', '/js/tilt.conf.js', '/js/tilt.conf.noglare.js', '/js/tilt.js', '/js/2dtilt.js', '/fonts/Hacked-KerX.ttf', '/fonts/SmoothElegantRegular-ZLv3.ttf', '/fonts/LigaJetBrainsMonoNerdFont-Regular.ttf', '/fonts/Big500-8MLOM.ttf', '/fonts/Monoton.ttf', '/fonts/RockSalt-Regular.ttf', '/fonts/audiowide.ttf'];
+self.addEventListener('install', function (event) {
+ event.waitUntil(caches.open(cacheName).then(function (cache) {
+ return cache.addAll(resourceToPrecache);
+ }));
+});
+self.addEventListener('fetch', function (event) {
+ event.respondWith(caches.match(event.request).then(function (cachedResponse) {
+ return cachedResponse || fetch(event.request);
+ }));
}); \ No newline at end of file
diff --git a/src/sw.js b/src/sw.js
new file mode 100644
index 00000000..26cc14a0
--- /dev/null
+++ b/src/sw.js
@@ -0,0 +1,57 @@
+const cacheName = 'cache-v1'
+const resourceToPrecache = [
+ '/',
+ '/index.html',
+ '/404.html',
+ '/pages/info/about.html',
+ '/pages/repo/github/repos.html',
+ '/css/style.css',
+ '/css/404.css',
+ '/css/index.css',
+ '/css/ghrepo.css',
+ '/css/about.css',
+ '/css/devicon.min.css',
+ '/js/main.js',
+ '/js/about.js',
+ '/js/dynamicBlob.js',
+ '/js/getrepo.js',
+ '/js/hacktype.js',
+ '/js/header.js',
+ '/js/index.js',
+ '/js/mouseblob.js',
+ '/js/randomblob.js',
+ '/js/rbg.js',
+ '/js/tilt.conf.js',
+ '/js/tilt.conf.noglare.js',
+ '/js/tilt.js',
+ '/js/2dtilt.js',
+ '/fonts/Hacked-KerX.ttf',
+ '/fonts/SmoothElegantRegular-ZLv3.ttf',
+ '/fonts/LigaJetBrainsMonoNerdFont-Regular.ttf',
+ '/fonts/Big500-8MLOM.ttf',
+ '/fonts/Monoton.ttf',
+ '/fonts/RockSalt-Regular.ttf',
+ '/fonts/audiowide.ttf'
+ // '/css/',
+ // '/js/',
+ // '/pages/',
+ // '/fonts/'
+]
+
+self.addEventListener('install', event => {
+ // console.log("Service Worker: Installed");
+ event.waitUntil(
+ caches.open(cacheName)
+ .then(cache => {
+ return cache.addAll(resourceToPrecache)
+ })
+ )
+})
+
+self.addEventListener('fetch', event => {
+ event.respondWith(caches.match(event.request)
+ .then(cachedResponse => {
+ return cachedResponse || fetch(event.request);
+ })
+ );
+}); \ No newline at end of file