Deploying your site

You will need to install the Firebase CLI to deploy your static web app.

The Firebase CLI can be installed with a single command:

npm install -g firebase-tools

Now, let's deploy our HelpDesk application on cloud. We have two projects for HelpDesk: react app (a project called code) and server app (a project called node). Let's first host or deploy our client-side react app on Firebase Hosting.

Go inside your project directory (code) and run the following command to initialize the configurations:

firebase init

As shown in the following screenshot, it will ask you "which Firebase feature do you want to set up for this folder?," and you need to select 'Hosting':

It will create a firebase.json file in the root directory of your project. The structure of the firebase.json will look like this:

{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}

The public property tells Firebase which directory is to be uploaded to hosting. The directory must exist in your project directory.

You can now deploy your site using the following command:

firebase deploy

It will ask you to do Firebase CLI login. You can do it using the following command:

firebase login --reauth

After a successful login, you can run the firebase deploy command again to deploy your app:

After successful deployment, you will a Hosting URL of your project, which is like https://YOUR-FIREBASE-APP>.firebaseapp.com. In our case, it is https://demoproject-7cc0d.firebaseapp.com/. 60. Now you can go and hit the generated URL and confirm that it is accessible:

Yay! We have deployed our first app on Firebase Hosting. You can also check the URL in your Firebase console under Hosting section:

You can also configure your custom domain by clicking on the Connect Domain button. It will guide you through a wizard to configure your own domain.

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

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