-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsw-build.js
More file actions
25 lines (20 loc) · 804 Bytes
/
sw-build.js
File metadata and controls
25 lines (20 loc) · 804 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
import { injectManifest } from "workbox-build";
let workboxConfig = {
globDirectory: "build",
globPatterns: ["favicon.ico", "index.html", "privacy.html", "assets/**/*", "images/icons/*","manifest.webmanifest"],
globIgnores: [
"**/*.map",
"**/*.txt"
],
swSrc: "src/sw/service-worker.js",
swDest: "build/sw.js",
// Vite uses content hashes in filenames (e.g. index-BxK3a1F2.js)
dontCacheBustURLsMatching: new RegExp("\\.[a-f0-9]{8}\\."),
// 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.`
);
});