modifying angular ngsw-worker.js

55 views Asked by At

I need to mdify the ngsw-worker.js file in angular14, but I am wondering is it possible or not!? and how can I rename the ngsw-worker.js to like ngsw.js?

this file is located in my app node-module

1

There are 1 answers

0
Wilt On

You register the script for your service worker when importing the ServiceWorkerModule in your application module:

imports: [
  ServiceWorkerModule.register('/ngsw-worker.js', { enabled: environment.production }),
],

You could pass any other file name for your service worker there with your custom content.

See for more information the official Angular documentation on the ServiceWorkerModule here.