ACTIVITY 15 : Deploy to Firebase
To deploy your Angular project to Firebase, follow these steps:
Step 1: Install Firebase CLI
Make sure you have Node.js installed, then install the Firebase CLI globally using npm:
npm install -g firebase-tools
Step 2: Log in to Firebase
Log in to your Firebase account from the terminal:
firebase login
Step 3: Initialize Firebase in Your Project
Navigate to your Angular project directory and initialize Firebase:
cd C:\Users\Teacher\AngularComponent
firebase init
Select Hosting when prompted.
Choose an existing Firebase project or create a new one.
Set the Public Directory
Identify Your Project's Build Output Directory: If your Angular project is named Angular Component, your public directory (where the build files will be located) will usually be:
dist/angular-component
Continue with Configuration
Single Page Application Configuration: If prompted whether to configure as a single-page app, select Yes.
Finish Initialization: Follow any additional prompts to complete the Firebase initialization
Step 4: Build Your Angular Project
If you're using Angular CLI version 18.2.7, you should use the --configuration
flag for building your project and not this one: ng build --prod
Here’s how to proceed:
ng build --configuration production
Step 5: Deploy to Firebase
Now, you can deploy your project to Firebase Hosting:
firebase deploy
Step 6: Access Your Deployed Application
Once the deployment is complete, Firebase will provide a hosting URL. You can access your deployed Angular application at that URL.