stack over
stack over

Reputation: 65

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

Upvotes: 0

Views: 342

Answers (1)

Kavinda Senarathne
Kavinda Senarathne

Reputation: 2004

Try:

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

inside app.module.ts

Upvotes: 1

Related Questions