Skip to content

Commit a289e4d

Browse files
committed
feat: initial PWA config
1 parent 1b02a53 commit a289e4d

File tree

7 files changed

+123
-3
lines changed

7 files changed

+123
-3
lines changed

angular.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
"maximumError": "8kB"
6868
}
6969
],
70-
"outputHashing": "all"
70+
"outputHashing": "all",
71+
"serviceWorker": "ngsw-config.json"
7172
},
7273
"development": {
7374
"optimization": false,

ngsw-config.json

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

package-lock.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@angular/material": "^20.2.7",
2525
"@angular/platform-browser": "^20.3.3",
2626
"@angular/router": "^20.3.3",
27+
"@angular/service-worker": "^20.3.3",
2728
"prettier": "^3.5.3",
2829
"rxjs": "~7.8.0",
2930
"tslib": "^2.3.0",
@@ -42,4 +43,4 @@
4243
"karma-jasmine-html-reporter": "~2.1.0",
4344
"typescript": "~5.8.2"
4445
}
45-
}
46+
}

public/manifest.webmanifest

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "RSS reader",
3+
"short_name": "Feedz",
4+
"display": "standalone",
5+
"scope": "./",
6+
"start_url": "./",
7+
"icons": [
8+
{
9+
"src": "icons/icon-72x72.png",
10+
"sizes": "72x72",
11+
"type": "image/png",
12+
"purpose": "maskable any"
13+
},
14+
{
15+
"src": "icons/icon-96x96.png",
16+
"sizes": "96x96",
17+
"type": "image/png",
18+
"purpose": "maskable any"
19+
},
20+
{
21+
"src": "icons/icon-128x128.png",
22+
"sizes": "128x128",
23+
"type": "image/png",
24+
"purpose": "maskable any"
25+
},
26+
{
27+
"src": "icons/icon-144x144.png",
28+
"sizes": "144x144",
29+
"type": "image/png",
30+
"purpose": "maskable any"
31+
},
32+
{
33+
"src": "icons/icon-152x152.png",
34+
"sizes": "152x152",
35+
"type": "image/png",
36+
"purpose": "maskable any"
37+
},
38+
{
39+
"src": "icons/icon-192x192.png",
40+
"sizes": "192x192",
41+
"type": "image/png",
42+
"purpose": "maskable any"
43+
},
44+
{
45+
"src": "icons/icon-384x384.png",
46+
"sizes": "384x384",
47+
"type": "image/png",
48+
"purpose": "maskable any"
49+
},
50+
{
51+
"src": "icons/icon-512x512.png",
52+
"sizes": "512x512",
53+
"type": "image/png",
54+
"purpose": "maskable any"
55+
}
56+
]
57+
}

src/app/app.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ import { provideRouter, withViewTransitions } from '@angular/router'
88
import { routes } from './app.routes'
99
import { provideHttpClient, withInterceptors } from '@angular/common/http'
1010
import { authCookiesInterceptor } from './intercepters/auth-cookies-interceptor'
11+
import { provideServiceWorker } from '@angular/service-worker'
12+
import { environment } from '../environments/environment'
1113

1214
export const appConfig: ApplicationConfig = {
1315
providers: [
1416
provideBrowserGlobalErrorListeners(),
1517
provideZoneChangeDetection({ eventCoalescing: true }),
1618
provideRouter(routes, withViewTransitions()),
1719
provideHttpClient(withInterceptors([authCookiesInterceptor])),
20+
provideServiceWorker('ngsw-worker.js', {
21+
enabled: environment.production,
22+
registrationStrategy: 'registerWhenStable:30000',
23+
}),
1824
],
1925
}

src/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,20 @@
1414
href="favicon.ico"
1515
/>
1616
<link
17-
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap"
17+
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&amp;display=swap"
1818
rel="stylesheet"
1919
/>
2020
<link
2121
href="https://fonts.googleapis.com/icon?family=Material+Icons"
2222
rel="stylesheet"
2323
/>
24+
<link
25+
rel="manifest"
26+
href="manifest.webmanifest"
27+
>
2428
</head>
2529
<body class="mat-typography">
2630
<app-root></app-root>
31+
<noscript>Please enable JavaScript to continue using this application.</noscript>
2732
</body>
2833
</html>

0 commit comments

Comments
 (0)