简体   繁体   中英

PWA not working with Angular Pre Rendering

I' working with Angular 10 Universal project.

When I run below command

"build:ssr": "ng build --prod && ng run PROJECT:server:production && node dist/PROJECT/server/main.js",

I could see the service-workers getting registed.

So now If I run the below command, I could see all the pages getting rendered but ngsw files are not getting generated and in browser also service workers are not registed.

"prerender": "ng run PROJECT:prerender"

What I'm going wrong here ? Please guide

Try:

ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production, scope: './', registrationStrategy: 'registerImmediately' })

inside app.module.ts

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM