Last active
October 26, 2018 22:55
-
-
Save zevdg/552530c973e01c9ff06ed14fb71465a8 to your computer and use it in GitHub Desktop.
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
// see https://github.com/GoogleChrome/workbox/issues/1384#issuecomment-433550967 | |
function precacheManifestHack() { | |
console.log( | |
chalk.red( | |
"Applying dirty hack for https://github.com/GoogleChrome/workbox/issues/1384#issuecomment-433550967" | |
) | |
); | |
const globPath = path.join( | |
__dirname, | |
"/..", | |
"dist", | |
"precache-manifest.*.js" | |
); | |
glob(globPath, function(err, matches) { | |
if (err) { | |
throw err; | |
} | |
if (matches.length !== 1) { | |
throw new Error("matches.length for " + globPath + " !== 1"); | |
} | |
const filepath = matches[0]; | |
let self = {}; | |
eval(fs.readFileSync(filepath, "utf8")); | |
let manifest = self.__precacheManifest; | |
let hash = manifest.filter(route => route.url === "/index.html")[0] | |
.revision; | |
manifest.push({ url: "/", revision: hash }); | |
const outputStr = "self.__precacheManifest = " + JSON.stringify(manifest); | |
fs.writeFileSync(filepath, outputStr); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment