Open EKliptus opened 7 months ago
I guess the problem is with Astro...
The script tag and the ts source script /src/pwa.ts
is not process as imported ts file by Astro. TS script import in the {...}
is considering as it is.
So the app (console) search for a http://localhost:4321/src/scripts/pwa.ts
that not exist...
With <script src="/src/pwa.ts"></script>
in index.astro file : astro process and bundle the script.
It is not a problem with vite-plugin-pwa, but if anyone has a solution to conditionally import a script in an Astro file ? I need it ...
Thanks
Why do you need to include the script this way? if you disable the pwa, the astro pwa integration will create a dummy virtual module.
Why do you need to include the script this way? if you disable the pwa, the astro pwa integration will create a dummy virtual module.
Because when I want to disable the PWA integration I don't want anything in the build that related to pwa integration... And when PWA integration is disabled and when load with Githubissues.
See this repository to reproduce : https://gitlab.com/ekliptus49/vite-plugin-pwa-astro-minimal-sw-issue See minimum this file : https://gitlab.com/ekliptus49/vite-plugin-pwa-astro-minimal-sw-issue/-/blob/master/src/pages/index.astro
pnpm build
do not generate SW.js (and workbox-x.js) whenregisterSW()
function is inpwa.js
that was conditionally (true) import in html. like this :{ true && <script src="/src/pwa.ts"></script> }
in index.astro fileI guess vite-plugin-pwa try to determine if the registerSW() was triggered before generate SW. And the conditionnal html script import in
{...}
isn't follow.. ?I don't have found any " registerSW() triggered flag " on vite-plugin-pwa source code.
Why registerSW() call is needed to generate SW.js with genrateSW strategie ???