Last active
April 15, 2020 23:29
-
-
Save cnp96/aaba58ae5e400c25ad586f51f7bf3ca8 to your computer and use it in GitHub Desktop.
src/sw-build.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const workboxBuild = require("workbox-build"); | |
const buildSW = () => { | |
// The build is expected to fail if the | |
// sw install rules couldn't be generated. | |
// Add a catch block to handle this scenario. | |
return workboxBuild | |
.injectManifest({ | |
swSrc: "src/sw-custom.js", // custom sw rule | |
swDest: "build/sw.js", // sw output file (auto-generated | |
globDirectory: "build", | |
globPatterns: ["**/*.{js,css,html,png,svg}"], | |
maximumFileSizeToCacheInBytes: 5 * 1024 * 102, | |
}) | |
.then(({ count, size, warnings }) => { | |
warnings.forEach(console.warn); | |
console.info(`${count} files will be precached, | |
totaling ${size / (1024 * 1024)} MBs.`); | |
}); | |
}; | |
buildSW(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment