Skip to content

Commit 0709a4b

Browse files
committed
feat(web): ServiceWorker & PWA enabled
1 parent 436569e commit 0709a4b

16 files changed

Lines changed: 243 additions & 228 deletions

angular.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@
198198
"tsConfig": "apps/web/tsconfig.app.json",
199199
"assets": [
200200
"apps/web/src/favicon.ico",
201-
"apps/web/src/assets"
201+
"apps/web/src/assets",
202+
"apps/web/src/manifest.json"
202203
],
203204
"styles": [
204205
"apps/web/src/styles.scss"
@@ -229,7 +230,9 @@
229230
"maximumWarning": "2mb",
230231
"maximumError": "5mb"
231232
}
232-
]
233+
],
234+
"serviceWorker": true,
235+
"ngswConfigPath": "apps/web/ngsw-config.json"
233236
}
234237
}
235238
},

apps/web/ngsw-config.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"index": "/index.html",
3+
"assetGroups": [
4+
{
5+
"name": "app",
6+
"installMode": "prefetch",
7+
"resources": {
8+
"files": [
9+
"/favicon.ico",
10+
"/index.html",
11+
"/*.css",
12+
"/*.js"
13+
]
14+
}
15+
}, {
16+
"name": "assets",
17+
"installMode": "lazy",
18+
"updateMode": "prefetch",
19+
"resources": {
20+
"files": [
21+
"/assets/**",
22+
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
23+
]
24+
}
25+
}
26+
]
27+
}

apps/web/src/app/app.module.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ import { NgModule } from '@angular/core';
33

44
import { AppComponent } from './app.component';
55
import { RouterModule } from '@angular/router';
6+
import { ServiceWorkerModule } from '@angular/service-worker';
7+
import { environment } from '../environments/environment';
68

79
@NgModule({
810
declarations: [AppComponent],
911
imports: [
1012
BrowserModule.withServerTransition({ appId: 'serverApp' }),
11-
RouterModule.forRoot([], { initialNavigation: 'enabled' })
13+
RouterModule.forRoot([], { initialNavigation: 'enabled' }),
14+
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production })
1215
],
1316
providers: [],
1417
bootstrap: [AppComponent]
6.36 KB
Loading
7.51 KB
Loading
8.44 KB
Loading
8.95 KB
Loading
21.4 KB
Loading
34.5 KB
Loading
3.41 KB
Loading

0 commit comments

Comments
 (0)