Deploy Angular app to Firebase hosting
Hosting an angular app on firebase is really easy.
Prerequisites:
Node and angular-cli.
Steps:
To deploy and app:
-
Create Angular App, or use already created Angular App.
-
Create project in Firebase console. Your app’s url name will be:
<project-id>.firebase-app.com -
Install Firebase tools. In order to deploy to Firebase, we’ll need the Firebase CLI tools
npm install -g firebase-tools -
Login to Firebase
firebase loginThis will open a browser tab, where you can login.
-
Initiliaze Firebase in your project. Go to your project folder and run this command:
firebase initFollwo the steps:
- Are you ready to proceed? Yes
- Which Firebase CLI features? Hosting (In the future, use whatever you need! Press space to select.)
- Select a default Firebase project? (Choose whatever app you created in the earlier steps)
- What do you want to use as your public directory? dist (This is important! Angular creates the dist folder.)
- Configure as a single-page app? Yes
Once you initilize the app, two files will be created in the folder:
.firebaserc
{ "projects": { "default": "project-id" } }.firebase.json
{ "hosting": { "public": "dist", "rewrites": [ { "source": "**", "destination": "/index.html" } ] } } -
Build Your Angular App
ng build --prodThis will build your angular application, where you will have a
distfolder, inside this folder will be yourindex.htmlsingle page application. -
Deploy
firebase deployIf everything went well, then your application will be deployed and you will see its url on the console.
Buy me a cup of coffee with ETH:
0x681a83007bC52C0bF42B41263Dc498f9Ef7af02A
Discussion
Comments are not enabled on this build. Production uses Giscus (GitHub Discussions) when the repository secrets are set.