From 27e19a04d6f2b14943a0bb4a9b7414382591d4e0 Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Tue, 13 Oct 2020 11:38:44 +0200 Subject: [PATCH] fix(workbox): precache `start_url` (resolves #372) --- lib/manifest/module.js | 1 + lib/workbox/options.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/manifest/module.js b/lib/manifest/module.js index 741e1fbb..a1b53e19 100755 --- a/lib/manifest/module.js +++ b/lib/manifest/module.js @@ -40,6 +40,7 @@ module.exports = function nuxtManifest (nuxt, pwa) { nuxt.options.manifest = {} } Object.assign(nuxt.options.manifest, manifest) + Object.assign(pwa.manifest, manifest) // Register webpack plugin to emit manifest const manifestSource = JSON.stringify(manifest, null, 2) diff --git a/lib/workbox/options.js b/lib/workbox/options.js index 858042bc..775c148e 100644 --- a/lib/workbox/options.js +++ b/lib/workbox/options.js @@ -61,6 +61,11 @@ function getOptions (nuxt, pwa) { }) } + // Add start_url to precaching + if (pwa.manifest && pwa.manifest.start_url) { + options.preCaching.unshift(pwa.manifest.start_url) + } + // Add offlineAssets to precaching if (options.offlineAssets.length) { options.preCaching.unshift(...options.offlineAssets)