Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SW for vue-cli with Google's workbox
// eslint-disable-next-line no-undef
workbox.setConfig({
debug: false
})
workbox.core.skipWaiting()
workbox.precaching.precacheAndRoute([])
workbox.routing.registerRoute(
/\.(?:png|gif|jpg|jpeg|svg)$/,
workbox.strategies.staleWhileRevalidate({
cacheName: 'images',
plugins: [
new workbox.expiration.Plugin({
maxEntries: 60,
maxAgeSeconds: 30 * 24 * 60 * 60 // 30 Days
})
]
})
)
workbox.routing.registerRoute(
new RegExp('^https://firestore\\.googleapis\\.com/'),
workbox.strategies.networkFirst({
cacheName: 'api'
})
)
workbox.routing.registerRoute(
new RegExp('https://fonts.(?:googleapis|gstatic).com/(.*)'),
workbox.strategies.cacheFirst({
cacheName: 'googleapis',
plugins: [
new workbox.expiration.Plugin({
maxEntries: 30
})
]
})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.