Open ranma42 opened 3 weeks ago
https://github.com/angular/angular/issues/23613 is related: basically it covers all of the cases in which a proxy mangles the files, not just the mangling performed by the vite dev server. IIUC the conclusion is that the expected approach is to ensure that the file digests match those listed in ngsw.json; even though disabling the hash check has been proposed, it looks like it is considered too fragile.
The root cause of the issue is that Vite will transform all JS, CSS and HTML files during request time, this will cause of the hashes in the manifest to be invalid.
Command
serve
Is this a regression?
The previous version in which this bug was not present was
Angular 16
Description
Serving a PWA with the default dev server is now broken. Specifically, the vite dev server apparently mangles the files emitted by the previous build steps, but does not recompute the hashes stored in
ngsw.json
. This results in the service worker being installed, but not really serving any file.It is still possible to use the "old" (webpack-based) dev server that is apparently not affected by this.
Minimal Reproduction
Basically the steps are:
ng new
ng add @angular/pwa
ng serve
A full repo reproducing the issue is https://github.com/ranma42/pwa-repro From this repo, the needed steps are:
npm install
ng serve
Note that the repo contains both a revision that reproduces the issue and one that configures the build to use webpack for comparison, to show that in that case the dev server works as intended. Also note that to properly check what is going on, you might want to clear the browser state by opening the inspector and (in Chrome-based browsers) going to Application -> Storage -> Clear site data
With the webpack dev server, http://localhost:4200/ngsw/state reports
Exception or Error
Your Environment
Anything else relevant?
No response