Skip to content

Commit

Permalink
Add manual changes to make dist2 progressive
Browse files Browse the repository at this point in the history
The dist2 folder was built using npm run build, and then updated manually afterwards
  • Loading branch information
ceddlyburge committed Jun 22, 2018
1 parent 3f6b2d6 commit ab5fd02
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
Binary file added dist2/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions dist2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
<head>
<meta charset="utf-8" />
<title>Elm SPA example</title>
<link rel="manifest" href="/manifest.json">
</head>
<body>
<div id="main"></div>
<script src="/app.js"></script>
<script>
if('serviceWorker' in navigator) {
navigator.serviceWorker
.register('/service-worker.js')
.then(function() { console.log("Service Worker Registered"); });
}
</script>
</body>
</html>
15 changes: 15 additions & 0 deletions dist2/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "Progessive Elm",
"name": "Minimal progressive Elm App, to demonstrate the steps involved",
"icons": [
{
"src": "icon.png",
"sizes": "192x192",
"type": "image/png"
}
],
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
26 changes: 26 additions & 0 deletions dist2/service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
self.addEventListener('install', function(e) {
e.waitUntil(
caches.open('progessive-elm').then(function(cache) {
return cache.addAll([
'/',
'/index.html',
]);
})
);
});

self.addEventListener('fetch', function(event) {
console.log('Service Worker Intercept: ' + event.request.url);

event.respondWith(

caches.match(event.request).then(function(response) {

console.log('Service Worker Serve: ' + event.request.url);

return response || fetch(event.request);

})

);
});

0 comments on commit ab5fd02

Please sign in to comment.