forked from gdgphilippines/devfest2018
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkbox.config.js
More file actions
52 lines (49 loc) · 1.33 KB
/
workbox.config.js
File metadata and controls
52 lines (49 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const packages = require('./package.json');
module.exports = {
cacheId: packages.name,
globDirectory: 'public/',
globPatterns: [
'**/*.{html,json,js,css,map,svg,jpg,png,tff,woff,woff2}'
],
swDest: 'public/service-worker.js',
importWorkboxFrom: 'local',
skipWaiting: true,
clientsClaim: true,
navigateFallback: '/index.html',
navigateFallbackWhitelist: [/^(?!(\/__)|(\/service-worker\.js)|(\/_bundle-sizes\.html)|(\/_statistic\.html)|(\/_statistic\.json))/],
// Define runtime caching rules.
runtimeCaching: [
{
// Match any request ends with .png, .jpg, .jpeg or .svg.
urlPattern: /\.(?:png|jpg|jpeg|svg)$/,
// Apply a cache-first strategy.
handler: 'cacheFirst',
options: {
cacheName: `${packages.name}-images`,
expiration: {
maxAgeSeconds: 31536000
}
}
},
{
urlPattern: /^https:\/\/www.gstatic.com\/firebasejs\/.*/,
handler: 'cacheFirst',
options: {
cacheName: `${packages.name}-firebase`,
expiration: {
maxAgeSeconds: 3600
}
}
},
{
urlPattern: /^https:\/\/www.google-analytics.com\/analytics.js/,
handler: 'networkFirst',
options: {
cacheName: `${packages.name}-analytics`,
expiration: {
maxAgeSeconds: 60
}
}
}
]
};