-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Service Worker does not get registered #6
Comments
@thedivac I'm preparing |
Hi @userquin, I gave the latest version of @vite-pwa/create-pwa a try and the service worker installs right away in the built app👍 I think the reason why it is not working out of the box for me is because I am using a remix app in SPA mode. I can see the registerSW gets called in the build/server/index.js file in your template (which never gets created in SPA mode). I've published a simple repo created with npx create-remix@latest --template remix-run/remix/templates/spa and added the pwa setup. The service worker gets created but isn't installed in the build. (I assume we need to put the code to register the sw either in the index.html or the entry.client.ts) |
I'll check it later, in the meantime try to include pwa assets and badge in your components folder (copy/paste them from the pwa template) and add it to your root.tsx. Since we don't have the index.html entry, there is no way to add the sw registration, you need to use worbox window (via any virtual pwa module, vanillajs or react). |
I don't know where I copied this from, but right now I am using a pwa.js file:
And I'm importing this file in entry.client.js. It seems to be doing its job. |
Try creating a new project via @vite-pwa/create-pwa, follow the prompts and check the generated project: PWA assets can be found in the remix template => beware, it is not a template, just a few resources to copy after running remix-run template from the create-pwa cli. |
Remix customizations can be found here: https://github.com/vite-pwa/create-pwa/blob/main/src/customize/remix.ts EDIT: will run after running remix-run template, this one https://github.com/vite-pwa/create-pwa/blob/main/src/prompts.ts#L96 We can also add more templates like SPA... (PR welcome ;) ) |
First of all thanks for working on a remix template for vite-pwa!
I'm currently converting a CRA SPA into a remix app. I've followed the starting guide, this is my vite.config.js:
The guide makes it sound like this is all it takes to create and register the web worker?
I can see that the service worker gets generated and there is a registerSW.js file in the build, but this file never gets called.
Do I need to import the registerSW.js file somewhere manually? Or how is this supposed to work?
Thankful for a pointer in the right direction!
The text was updated successfully, but these errors were encountered: