-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsw-build.js
More file actions
25 lines (20 loc) · 770 Bytes
/
sw-build.js
File metadata and controls
25 lines (20 loc) · 770 Bytes
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
const { injectManifest } = require("workbox-build");
let workboxConfig = {
globDirectory: "out",
globPatterns: ["favicon.ico", "index.html", "_next/**/*", "app.webmanifest"],
globIgnores: [
"**/*.map",
"**/*.txt"
],
swSrc: "src/sw/service-worker.js",
swDest: "out/sw.js",
// React takes care of cache busting for JS and CSS (in prod mode)
dontCacheBustURLsMatching: new RegExp(".+.chunks.(?:js|css)"),
// By default, Workbox will not cache files larger than 2Mb (might be an issue for dev builds)
maximumFileSizeToCacheInBytes: 4 * 1024 * 1024, // 4Mb
};
injectManifest(workboxConfig).then(({ count, size }) => {
console.log(
`Generated ${workboxConfig.swDest}, which will precache ${count} files, totaling ${size} bytes.`
);
});