2

I have problem with situaton:

  • when I use the command ng serve --prod to Service Worker is registered
  • when I use the command ng build --prod to Service Worker is NOT registered. Missing files in dist
    • files ngsw
Tony Ngo
  • 19,166
  • 4
  • 38
  • 60
startNet
  • 274
  • 1
  • 10

1 Answers1

2

Angular ng serve does not work with service worker. You need to do a prod build and then serve the application from the /dist folder. You can use any web server you prefer: npm http-server or the web server as Chrome Extension. This way you can test the service worker locally.

You can have a look at this article, where I explain step by step how to create a PWA with Angular.

The article also refers to a Github Project with a running Angular PWA app, that you can use as starting point or to compare it with your code.

Francesco
  • 9,947
  • 7
  • 67
  • 110