-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgulpfile.js
43 lines (41 loc) · 1.17 KB
/
gulpfile.js
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
const gulp = require('gulp');
const workbox = require('workbox-build');
gulp.task('generate-sw', () => {
return workbox.generateSW({
cacheId: "hymnsrepo",
globDirectory: "./public",
globPatterns: [
"**/*.{js,json,html,css,png,jpg,gif,svg,eot,ttf,woff,woff2,otf}"
],
swDest: "./public/sw.js",
modifyURLPrefix: {
"": "/"
},
clientsClaim: true,
skipWaiting: true,
ignoreURLParametersMatching: [/./],
offlineGoogleAnalytics: true,
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024, // 5 MiB
runtimeCaching: [
{
urlPattern: /^https:\/\/fonts\.gstatic\.com/,
handler: "CacheFirst",
options: {
cacheName: "google-fonts",
expiration: {
maxAgeSeconds: 60 * 60 * 24 * 365,
maxEntries: 30
},
},
},
],
}).then(({warnings}) => {
// In case there are any warnings from workbox-build, log them.
for (const warning of warnings) {
console.warn(warning);
}
console.info('Service worker generation completed.');
}).catch((error) => {
console.warn('Service worker generation failed:', error);
});
});