shaunchander / astro-pwa-starter

✨ An opinionated Astro starter for building robust static websites.
astro-pwa-starter.vercel.app
205 stars 44 forks source link

vite-plugin-pwa running before html files are finished building - no pages being precached in sw.js #5

Closed areimel closed 1 year ago

areimel commented 1 year ago

Hello - Thank you for making this starter project, it's pretty much exactly what I was looking for to build a PWA to help my friend on his job. I just have a question/issue about how the precaching works.

I'm trying to have vite-plugin-pwa precache all html pages on install, but when I add a line for html files to the globPatterns option in 'astro.config.ts' (line 50) I get an error saying there are no html files to precache. Is there a way for me to delay vite-plugin-pwa from scanning for files until after the html files are ready? Or is there something else this is being caused by?

Thank you for any help you can offer.

Here's a link to the repo, not much is changed from the base project besides adding a blog section taken from another Astro starter template. https://github.com/Planet-Caravan-Studios/Safety-Manual-WebApp/tree/newVersion--PWA

craigwmiller2 commented 1 year ago

I have run into the same issue as well when trying to precache the HTML files in my project. It looks like Workbox starts and finishes caching the files before Astro generates the HTML files and, as a result, produces the notice that "One of the glob patterns doesn't match any files". Similar to @areimel, is there a way to delay when vite-plugin-pwa scans the dist folder so that there is adequate time for all the HTML files to generate?