Deploying to Firebase

PWAs should always be protected using HTTPS, even if there is no sensitive communication. Up until now, we have used http-server and increased the Lighthouse score to 92. The only thing we need to do is move to HTTPS.

In this section, we will deploy our app to Firebase and check our application's score over HTTPS.

First, let's make sure that we can create an account on Firebase by going to https://firebase.google.com/. Then, install the Firebase tools using npm:

> npm install -g firebase-tools

Verify that Firebase is installed by using the firebase -V command, which will return the version that's installed on your system.

Now, let's initialize Firebase in our root repository:

> firebase init
? Which Firebase CLI features do you want to setup for this folder? Press Space to select features, then Enter to confirm your choices. Hosting: Configure and deploy Firebase Hosting sites
? Select a default Firebase project for this directory: [create a new project]
? What do you want to use as your public directory? dist/electronic-store
? Configure as a single-page app (rewrite all urls to /index.html)? No
? File dist/electronic-store/index.html already exists. Overwrite? No

Now, let's go to the Firebase console, https://console.firebase.google.com/, and add a new project, let's name it electronic-store, you will see a unique project ID, such as in the image below electronic-store-41e9f, click Continue, and select Not at the moment for Google Analytics and then click Create Project:

We will be using the project ID while deploying our application.

Now, let's log in to Firebase in our Terminal by using the firebase login command. Then, we will deploy our application using the following command:

> firebase deploy --project electronic-store-41e9f

Once the command completes, you should see the hosting URL where you can access the website. Now, let's open the website in incognito mode and run our Lighthouse audit again:

We can see that we have a perfect score of 100 for Progressive Web App. We can also observe that the score for performance has increased from our last run.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.233.72