Skip to content
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

PWA not working #59

Closed
VittorioAccomazzi opened this issue Dec 31, 2021 · 3 comments
Closed

PWA not working #59

VittorioAccomazzi opened this issue Dec 31, 2021 · 3 comments

Comments

@VittorioAccomazzi
Copy link

VittorioAccomazzi commented Dec 31, 2021

I'm not able to get the service worker registering correctly with this template. Here are the steps to reproduce the problem :

  • install the template npx create-react-app@5.0.0 my-pwa --template redux-typescript
  • edit index.tsx to enable the service worker at line 21 as follow : serviceWorker.register();
  • build the application npm run build
  • serve the application with serve : serve -s build

The service workers are not installed, this is visible either setting a breakpoint as well as checking with Chrome's developer tools.

@VittorioAccomazzi
Copy link
Author

VittorioAccomazzi commented Dec 31, 2021

the registration fails at this line:
image
and the reason is that the file service-worker.js is not found and serve just sent the index.html file. So the problem is somewhere in the compilation step.

@markerikson
Copy link
Contributor

Any serviceworker setup is really part of Create-React-App's config - you might want to check over in that repo.

@VittorioAccomazzi
Copy link
Author

Thank you @markerikson. Indeed Create-React-App has changed, a solution to this problem is posted here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants