Skip to content
Snippets Groups Projects
Verified Commit 5f0b8cab authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Better exclusion for non-critical assets caching in service worker

parent 9b98e877
No related branches found
No related tags found
No related merge requests found
......@@ -24,17 +24,7 @@ workbox.core.clientsClaim();
// The precaching code provided by Workbox.
self.__precacheManifest = [].concat(self.__precacheManifest || []);
console.log('[sw] Files to be cached [before filtering]', self.__precacheManifest.length);
var excludedUrlsPrefix = [
'/js/locale-',
'/js/moment-locale-',
'/js/admin',
'/css/admin',
];
self.__precacheManifest = self.__precacheManifest.filter((e) => {
return !excludedUrlsPrefix.some(prefix => e.url.startsWith(prefix))
});
console.log('[sw] Files to be cached [after filtering]', self.__precacheManifest.length);
// workbox.precaching.suppressWarnings(); // Only used with Vue CLI 3 and Workbox v3.
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
......
......@@ -63,6 +63,12 @@ module.exports = {
// swSrc is required in InjectManifest mode.
swSrc: 'src/service-worker.js',
swDest: 'service-worker.js',
exclude: [
new RegExp('js/locale.*'),
new RegExp('js/moment-locale.*'),
new RegExp('js/admin.*'),
new RegExp('css/admin.*'),
]
},
iconPaths: {
favicon32: 'favicon.png',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment