Verified Commit 3efa8403 authored by Tim Vis茅e's avatar Tim Vis茅e
Browse files

Fix generated service worker, temporarily exclude caches causing errors

parent beb8405a
Pipeline #181868741 passed with stage
in 4 minutes and 52 seconds
......@@ -8,7 +8,7 @@ var pwaDeferredPrompt = null;
// Register service worker for PWA/offline usage
if('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/service-worker.js').then(registration => {
navigator.serviceWorker.register('/js/sw.js').then(registration => {
console.log('Service worker registered: ', registration);
}).catch(registrationError => {
console.log('Service worker registration failed: ', registrationError);
......
self.addEventListener('install', function(e) {
e.waitUntil(
caches.open('barbapappa').then(function(cache) {
return cache.addAll([
// TODO: improve this list, less resources, only necessary
'/css/app.css',
'/css/flag-icon.css',
'/css/glyphicons-packed.css',
'/css/semnatic.min.css',
'/img/logo/logo_square.png',
'/js/app.js',
'/js/jquery-packed.js',
'/js/lang.js',
'/js/quickbuy.js',
'/js/semantic.min.js',
]);
})
);
});
self.addEventListener('fetch', function(e) {
// TODO: remove console log here, only to debug?
console.log(e.request.url);
e.respondWith(
caches.match(e.request).then(function(response) {
return response || fetch(e.request);
})
);
});
......@@ -10,7 +10,13 @@ mix.webpackConfig({
onBuildStart:['php artisan lang:js --compress --quiet'],
onBuildEnd:[],
}),
new GenerateSW(),
new GenerateSW({
// TODO: do not exclude common files
exclude: [
/.*\.(js|css)/
],
swDest: 'js/sw.js',
}),
]
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment