DEV Community

loading...
Cover image for Deploy Application to Firebase

Deploy Application to Firebase

Madhankumar Anandan
Tech... Tech... Tech...
・2 min read

Deploy the ionic application in firebase

Installation

Make sure you have installed the firebase-tools. If not, please find the following command to install

npm install -g firebase-tools
Enter fullscreen mode Exit fullscreen mode

Login & Test the connection

  1. Login to Firebase.
firebase login:ci
Enter fullscreen mode Exit fullscreen mode

Firebase

  1. Check the list of projects available. It displays the list of projects available.
firebase projects:list
Enter fullscreen mode Exit fullscreen mode

Firebase project list

Initialize a project

Initialize the project with the following command.

firebase init
Enter fullscreen mode Exit fullscreen mode

Follow as per instructions and pick the Hosting and then select the project.
Post selection set of question will pop up

  • What do you want to use as your public directory? - Mention your build folder (e.g www).

  • Configure as a single-page app (rewrite all URLs to /index.html)? - No

  • Set up automatic builds and deploys with GitHub? - Y

It requests you to authorize the GitHub by CLI URL.

  • For which GitHub repository would you like to set up a GitHub workflow? (format: user/repository) - Updated the user and repository (e.g amkumar072/firebase-deploy-sample)

It will set up an account FIREBASE_SERVICE_ACCOUNT for your project.

  • Set up the workflow to run a build script before every deploy? (y/N) - Select depend upon your request. I have selected YES, then the next question will appear.

  • What script should be run before every deploy? (npm ci && npm run build) - Provide the build script/commands or else press enter to take the default.

  • Set up automatic deployment to your site's live channel when a PR is merged? (Y/n) - Select depend upon your request. I have selected NO.

Initialization is completed. By the time you would able to see the 3 files are created

  • .firebaserc
  • firebase.json
  • firebase-hosting-pull-request.yml Firebase init

Firebase commands

Deploy to Firebase

Now we are in the final part of the process. Deploy your project with the following commands.

note: Make sure the project is already built (npm run build)

firebase deploy
Enter fullscreen mode Exit fullscreen mode

Changes will deploy into Firebase and the URL will be displayed in Console.

Firebase deploy

Please find the source code in Github

Happy Deployment :)

Discussion (0)

Forem Open with the Forem app