Adding service worker cache

This commit is contained in:
Jeff Avallone
2018-02-10 16:08:42 -05:00
parent 97a61dc0f3
commit 40d08ddef8
5 changed files with 61 additions and 4 deletions
+1
View File
@@ -1 +1,2 @@
import '../../style.css';
import '../../service-worker';
+11
View File
@@ -0,0 +1,11 @@
if ('serviceWorker' in navigator && process.env.NODE_ENV === 'production') {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js')
.then(registration => {
console.log('SW registered:', registration);
})
.catch(registrationError => {
console.log('SW registration failed:', registrationError);
});
});
}