Angular CLI Commands and deploying Angular Application - chaitanyavangalapudi/devops-scripts GitHub Wiki
Some of the useful angular commands are
- ng new to initialize a new Angular project with a lot of settings.
- ng generate to generate something from a blueprint.
- ng serve to build the application and starts a web server.
- ng build to compile the application into an output directory. It creates the build of your project , converts all your ".ts files" and other files to the simple js files that browser can understand. So there is no need to run ng serve over the dist folder.
- ng test to run your unit tests with Karma the provided test runner.
- ng lint to lint you app code using tslint to ensure best practices of Angular.
Deploying Angular application using dist folder on Nginx
Once you run ng build with whatever options you input, it will generate a dist folder. You can add the dist folder as root to Nginx configuration to run the application.
Let us assume that the dist folder is copied to /home/application/dist, edit nginx.conf to add root as follows
server {
root /home/application/dist;
location / {
}
location /images/ {
}
}
After this, restart nginx server by running systemctl restart nginx
.
References: