Welcome to our comprehensive guide on building Angular apps using the ng build command! By the end of this tutorial, you'll be able to create, build, and deploy your very own Angular applications. Let's dive in!
ng build? 📝ng build is an Angular CLI command used to build an Angular application for production. It bundles the application along with all its dependencies and creates a single deployment unit.
Before we start, make sure you have Node.js and Angular CLI installed on your system. If you haven't installed them yet, follow the guides on our website:
Let's start by creating a new Angular app:
ng new my-angular-appReplace my-angular-app with the name you want for your project.
Navigate into your newly created app directory:
cd my-angular-appNow, let's build the app for production:
ng build --configuration productionThe --configuration production option tells Angular CLI to build the app using the production configuration.
After running the ng build command, you'll find a new folder called dist in your project directory. This folder contains the built version of your app. Inside the dist folder, you'll find the following directories:
my-angular-app: This directory contains the optimized JavaScript, CSS, and HTML files.assets: This directory contains your application's static files like images, fonts, etc.Now that you have your built app, you can deploy it to any web server. For the sake of this tutorial, we'll use GitHub Pages to host our app. If you don't have a GitHub account, sign up here.
Follow our guide on Deploying an Angular App on GitHub Pages to learn how to deploy your app.
What does the `ng build` command do?
Where can you find the built version of your Angular app?