Angular 7 - service worker not registered

前端 未结 3 836
余生分开走
余生分开走 2020-12-29 05:15

I did everything as written in \"https://angular.io/guide/service-worker-getting-started\" to make my application PWA.

Used exactly this commands:

n         


        
3条回答
  •  太阳男子
    2020-12-29 05:44

    It seems the service worker setup is broken for the @angular/cli@7.1.4:

    As a temporary solution you can register it manually yourself by modifying the file src/main.ts (Once fixed you can remove the manual service worker registration.):

    .....
    
    platformBrowserDynamic().bootstrapModule(AppModule).then(() => {
      if ('serviceWorker' in navigator && environment.production) {
        navigator.serviceWorker.register('/ngsw-worker.js');
      }
    }).catch(err => console.log(err));
    

    PS: Github issue created: https://github.com/angular/angular-cli/issues/13351

    PS: Github issue #2 created: https://github.com/angular/angular-cli/issues/15025

提交回复
热议问题