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
Login & Test the connection
- Login to Firebase.
firebase login:ci
- Check the list of projects available. It displays the list of projects available.
firebase projects:list
Initialize a project
Initialize the project with the following command.
firebase init
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
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
Changes will deploy into Firebase and the URL will be displayed in Console.
Please find the source code in Github
Happy Deployment :)
Top comments (0)