You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pnpm build do not generate SW.js (and workbox-x.js) when registerSW() function is in pwa.js that was conditionally (true) import in html.
like this : { true && <script src="/src/pwa.ts"></script> } in index.astro file
I 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 ???
The text was updated successfully, but these errors were encountered:
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 ...
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 <script> tag : I have an error trace ( registerSW : onRegisterError(error) ).
But I have see this error trace is only with "astro dev" not with the final prod build.
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 ???
The text was updated successfully, but these errors were encountered: