You have unlimited access as a PRO member
You are receiving a free preview of 3 lessons
Your free preview as expired - please upgrade to PRO
- Object Oriented Programming With TypeScript
- Angular Elements Advanced Techniques
- TypeScript - the Basics
- Cloud Scheduler for Firebase Functions
- Testing Firestore Security Rules With the Emulator
- How to Use Git and Github
- Infinite Virtual Scroll With the Angular CDK
- Build a Group Chat With Firestore
- Async Await Pro Tips
Deploying an Angular App to FirebaseEpisode 1.2 written by Jeff Delaney
Health Check: This lesson was last reviewed on and tested with these packages:
- firebase-tools v3.18
- angular v6
Find an issue? Let's fix it
You can host your Angular app anywhere and still take advantage of the Firebase backend, but nothing is easier than hosting it on Firebase directly. After some initial configuration, deploying updates to your app can be handled with a single command.
ng build --prod
ng build command will compile and minify your code in a single package in the
dist/ folder. You could drop the contents of this directory into virtually any static website hosting platform or even an S3 bucket and you’re site would be ready to serve traffic.
First, make sure you have the firebase tools package installed.
npm install -g firebase-tools
Second, log into your existing firebase account. You should have already created a firebase project for your production app. If not, create a new project now.
Third, initialize the project. You will only need to go through this process once. Make sure you are in the top level directory of your angular app.
You should see this after running firebase init from the command line.
For the most part, you can stick with the default settings, except for the following questions:
- Choose hosting on the first question.
- Change public folder to dist/your-app-name when asked (it defaults to public).
- Configure as single page app? Yes
- If firebase asks to overwrite your index.html file, just say NO.
Finally, deploy the app.
If all went well, your app should be alive and well on the firebase project URL.