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
Recent Posts
- Object Oriented Programming With TypeScript
- Angular Elements Advanced Techniques
- TypeScript - the Basics
- The Real State of JavaScript 2018
- 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 Firebase
Episode 1.2 written by Jeff DelaneyHealth 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.
Building the Production Code
ng build --prod |
Running the 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.
Deploying to Firebase
Install
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.
firebase login |
Initialize
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.
firebase init |
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.
Deploy
Finally, deploy the app.
firebase deploy |
If all went well, your app should be alive and well on the firebase project URL.