Deploy Angular App To Firebase Hosting
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 login
This will open a browser tab, where you can login.
- Initiliaze Firebase in your project.
Go to your project folder and run this command:
firebase init
Follwo 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 --prod
This will build your angular application, where you will have a
dist
folder, inside this folder will be yourindex.html
single page application. - Deploy
firebase deploy
If 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
Leave a comment