Fireship · @fireship
Angular 5 Service Worker - Hacker News PWA
Uploaded November 26, 2017 · Length 7:41
Summary
Angular 5 Service Worker - how to build a PWA with Angular CLI and Firebase
- angular 5 service worker
- pwa angular cli
- firebase hosting
- progressive web app
- angular service worker config
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
just last month angular 5 was released
- 0:01
and with it comes the new serviceworker
- 0:04
module that makes building progressive
- 0:05
web apps easier than ever before all we
- 0:08
need to do is set a few configuration
- 0:09
variables and angular will automatically
- 0:11
generate a serviceworker with our
- 0:13
production build in this video I'm going
- 0:15
to show you how to use the worker to
- 0:16
score 100 on a progressive web app on it
- 0:18
and I'll show you how to customize the
- 0:20
worker to fit the needs of your specific
- 0:22
application I'm going to do this by
- 0:24
creating my own version of hacker news
- 0:26
which is the gold standard for comparing
- 0:28
performance and usability across various
- 0:30
JavaScript frameworks if you're just
- 0:32
finding me for the first time make sure
- 0:33
to subscribe and for this video I have a
- 0:36
full working demo deployed to firebase
- 0:37
hosting feel free to mess around with it
- 0:39
and if you see anything you want to
- 0:41
optimize our fix send me a pull request
- 0:43
on github
- 0:44
before we get going I just want to point
- 0:45
out that service workers aren't
- 0:47
supported on all modern browsers Safari
- 0:49
and Microsoft edge or the main holdouts
- 0:51
but they should be supported in the
- 0:52
future at the time of this video the
- 0:54
serviceworker is only available in that
- 0:56
beta version of the angular CLI so
- 0:59
you'll want to install it with the next
- 1:00
tag and then make sure the version you
- 1:03
have installed is 1.6 or greater and if
- 1:06
you're starting from an existing angular
- 1:07
5 app you can simply create the files
- 1:09
I'm about to show you in the upcoming
- 1:10
steps here to create a new app with the
- 1:12
serviceworker configured automatically
- 1:14
run ng new with the serviceworker flag
- 1:17
then inside that new app the first place
- 1:19
I'm going to go is the angular CLI JSON
- 1:22
file inside here you'll want to add
- 1:24
manifest.json to the assets array we're
- 1:27
going to create this file manually here
- 1:29
in the next step then down here you'll
- 1:31
notice that the serviceworker option is
- 1:33
set to true which tells angular to
- 1:35
generate the serviceworker at Build time
- 1:36
from there you're going to create a web
- 1:39
app manifest in the source directory the
- 1:42
purpose of the manifest is to tell
- 1:43
browsers how to handle your web app
- 1:45
we're just going to set the bare minimum
- 1:47
options for now so we have a start URL
- 1:49
which is just the root and then you'll
- 1:51
need a theme color and background color
- 1:53
then you'll need to add some icons if
- 1:55
you want your app to be installable on
- 1:57
mobile devices the bare minimum is just
- 1:59
a 512 by 512 image but you can add


