-
Notifications
You must be signed in to change notification settings - Fork 2
/
workbox-config.cjs
80 lines (67 loc) · 1.71 KB
/
workbox-config.cjs
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
module.exports = {
skipWaiting: true,
clientsClaim: true,
globDirectory: 'public/',
globPatterns: [
'**/*.{html,js,css}',
],
globIgnores: [
// For now ignoring split chunks, since rollup-plugin-workbox is not as robust as the webpack version
'**/chunk*.js',
],
swDest: 'public/sw.js',
// Define runtime caching rules.
runtimeCaching: [{
// Match any request ends with .png, .jpg, .jpeg or .svg.
urlPattern: /(.*)index\.html$/,
// Apply a cache-first strategy.
handler: 'NetworkFirst',
options: {
// Use a custom cache name.
cacheName: 'critical-path',
// Only cache 10 images.
expiration: {
maxEntries: 1,
},
},
}, {
// Match any request ends with .png, .jpg, .jpeg or .svg.
urlPattern: /(.*)app\.js/,
// Apply a cache-first strategy.
handler: 'NetworkFirst',
options: {
// Use a custom cache name.
cacheName: 'critical-path',
// Only cache 10 images.
expiration: {
maxEntries: 1,
},
},
}, {
// Match any request ends with .png, .jpg, .jpeg or .svg.
urlPattern: /(.*)chunk(.*)\.js/,
// Apply a cache-first strategy.
handler: 'CacheFirst',
options: {
// Use a custom cache name.
cacheName: 'scripts',
// Only cache 10 images.
expiration: {
maxEntries: 100,
},
},
}, {
// Match any request ends with .png, .jpg, .jpeg or .svg.
urlPattern: /\.(?:png|jpg|jpeg|svg)$/,
// Apply a cache-first strategy.
handler: 'CacheFirst',
options: {
// Use a custom cache name.
cacheName: 'images',
// Only cache 10 images.
expiration: {
maxEntries: 100,
},
},
}],
};