10- Angular PWA
10- Angular PWA
10- Angular PWA
1 / 11
Angular
2 / 11
Angular
Pour ajouter un service worker à notre projet
ng add @angular/pwa
3 / 11
Angular
Pour ajouter un service worker à notre projet
ng add @angular/pwa
Résultat
3 / 11
Angular
Explication
référencement de manifest.webmanifest
ajout d’une balise meta pour theme-color
4 / 11
Angular
Nouveau contenu d’index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CoursAngular</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="manifest" href="manifest.webmanifest">
<meta name="theme-color" content="#1976d2">
</head>
<body>
<app-root></app-root>
<noscript>Please enable JavaScript to continue using this application
.</noscript>
</body>
</html>
5 / 11
Angular
Contenu de manifest.webmanifest
{
"name": "cours-angular",
"short_name": "cours-angular",
"theme_color": "#1976d2",
"background_color": "#fafafa",
"display": "standalone",
"scope": "./",
"start_url": "./",
"icons": [
{
"src": "assets/icons/icon-72x72.png",
"sizes": "72x72",
"type": "image/png",
"purpose": "maskable any"
},
]
}
6 / 11
Angular
Explication
short name : Le nom court de l’application (utilisé lorsque l’espace d’affichage est limité).
icons : Une liste d’icônes utilisées pour représenter l’application sur différents appareils
et plateformes.
7 / 11
Angular
Exécutons maintenant la commande suivante
ng build
8 / 11
Angular
Exécutons maintenant la commande suivante
ng build
Remarques
8 / 11
Angular
Exécutons maintenant la commande suivante
ng build
Remarques
8 / 11
Angular
9 / 11
Angular
Remarque
9 / 11
Angular
10 / 11
Angular
11 / 11
Angular
Remarque
Sans le service worker, on aurait eu le message There is no
Internet connection.
11 / 11