Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit b7d033a

Browse files
amcdnljelbourn
authored andcommitted
feat(sw): adds ngsw config (#350)
1 parent 3d5a970 commit b7d033a

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
lines changed

angular-cli.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"test": "test.ts",
1717
"tsconfig": "tsconfig.json",
1818
"prefix": "app",
19-
"serviceWorker": false,
19+
"serviceWorker": true,
2020
"styles": [
2121
"main.scss",
2222
"highlightjs/material-light.css",

ngsw-manifest.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/app/app-module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import {
3333
CanActivateComponentSidenav
3434
} from './pages/component-sidenav/component-sidenav-can-load-guard';
3535
import {HttpClientModule} from '@angular/common/http';
36+
import {ServiceWorkerModule} from '@angular/service-worker';
37+
import {environment} from '../environments/environment';
3638

3739
@NgModule({
3840
imports: [
@@ -44,7 +46,7 @@ import {HttpClientModule} from '@angular/common/http';
4446
HttpClientModule,
4547
MatNativeDateModule,
4648
RouterModule.forRoot(MATERIAL_DOCS_ROUTES),
47-
49+
ServiceWorkerModule.register('/ngsw-worker.js', {enabled: environment.production}),
4850
ComponentCategoryListModule,
4951
ComponentHeaderModule,
5052
ComponentListModule,

src/ngsw-config.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"index": "/index.html",
3+
"assetGroups": [{
4+
"name": "app",
5+
"installMode": "prefetch",
6+
"resources": {
7+
"files": [
8+
"/favicon.ico",
9+
"/index.html"
10+
],
11+
"versionedFiles": [
12+
"/*.bundle.css",
13+
"/*.bundle.js",
14+
"/*.chunk.js"
15+
]
16+
}
17+
}, {
18+
"name": "assets",
19+
"installMode": "prefetch",
20+
"resources": {
21+
"files": [
22+
"/assets/**"
23+
]
24+
}
25+
}, {
26+
"name": "static-assets",
27+
"installMode": "lazy",
28+
"updateMode": "prefetch",
29+
"resources": {
30+
"urls": [
31+
"https://fonts.googleapis.com/icon?family=Material+Icons",
32+
"https://fonts.googleapis.com/css?family=Roboto|Roboto+Mono",
33+
"https://ajax.googleapis.com/ajax/libs/hammerjs/2.0.8/hammer.min.js",
34+
"https://cdnjs.cloudflare.com/ajax/libs/web-animations/2.2.5/web-animations.min.js"
35+
]
36+
}
37+
}]
38+
}

0 commit comments

Comments
 (0)