From 91e69a2bd0c193818228280b4b7d33d2fca0f49d Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 6 Dec 2021 15:25:44 +0100 Subject: [PATCH] fix icons in manifest not being found --- scripts/build-plugins/manifest.js | 5 ++++- vite.config.js | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/build-plugins/manifest.js b/scripts/build-plugins/manifest.js index 560bce68..b79af2b2 100644 --- a/scripts/build-plugins/manifest.js +++ b/scripts/build-plugins/manifest.js @@ -32,7 +32,10 @@ module.exports = function injectWebManifest(manifestFile) { name: path.basename(iconFileName), source: imgData }); - icon.src = this.getFileName(ref); + // we take the basename as getFileName gives the filename + // relative to the output dir, but the manifest is an asset + // just like they icon, so we assume they end up in the same dir + icon.src = path.basename(this.getFileName(ref)); } const outputName = path.basename(absoluteManifestFile); const manifestRef = this.emitFile({ diff --git a/vite.config.js b/vite.config.js index caae8f4b..28f9f5a6 100644 --- a/vite.config.js +++ b/vite.config.js @@ -47,6 +47,8 @@ export default { // }, "hydrogen-legacy", [ // './legacy-polyfill', // ]), + // important this comes before service worker + // otherwise the manifest and the icons it refers to won't be cached injectWebManifest("assets/manifest.json"), injectServiceWorker("sw.js"), ],