Viktor Kolomiets
Viktor Kolomiets

Reputation: 21

Extend angular service worker (ngsw-worker.js)

I want to extend native service worker for angular pwa. Task: change all base fetched urls (called origin in sw) It needs for mirrors - on url for all mirrors in sw. I have tried to register custom sw via copy ngsw-worker.js and extend it, but it broke config and updating mechanism for sw (because i have to disable default serviceworker flag in angular.json for exclude default ngsw-worker.js file usage).

Upvotes: 1

Views: 903

Answers (1)

Viktor Kolomiets
Viktor Kolomiets

Reputation: 21

ServiceWorkerModule.register('custom-ngsw.js', {enabled: true, registrationStrategy: 'registerImmediately'})

just pass another file and copy whole code from sw. also files can be merged via importScripts('some.js');

Upvotes: 1

Related Questions