Member-only story
Serving Angular application on NGINX server

Angular or Angular 2+ is a JavaScript frontend framework based on MVC concept. If you are a web developer and you don’t know about Angular, that means you are living in a hole. At least you might have heard about AngularJS.
AngularJS became popular quickly because of its two way data binding. It was much easier to use data and event binding instead of writing thousands of lines of code in JavaScript. Not only that would be cumbersome, but very inefficient as you would have to write same code again and again when there is tiny change in application logic. Also, you would have to create your own logic to run digest cycle or DOM checking when some user interaction happens so that necessary action can be taken. These things and more were elevated by AngularJS.
But AngularJS in itself was not perfect. Lack of component architecture support, lack of building too, lack of CLI tool, lack of SEO support and more, was turn-off for most developers, when other frameworks like Backbone.js and Ember.js were emerging. Hence Google took different turn with Angular 2 (now just Angular) and came up with whole new design. It was so different from AngularJS that there was no practical advantage of having knowledge of AngularJS for those who wanted to learn Angular. Angular 2 still was not perfect until Angular version 4 came and things got much better.
Angular provides a CLI application at @angular-cli
node module which will help you create new Angular application using ng new app-name
command. It also provide lot of commands to do bunch of things with the app like to generate modules, classes, components, pipes, directives, services etc. Unlike AngularJS which was written in JavaScript, Angular uses typescript
for writing application logic. Angular CLI supports sass
out of the box and uses webpack to transpile TypeScript and SASS.
The cool thing about Angular CLI is, you don’t have to worry about setting up the project. With ng new
command, your Angular application files will be created by the CLI application and all latest dependencies will be installed automatically. Unlike AngularJS where you have to build the project on your own, combining all js
and css
files and uglifying it and what not, Angular CLI provide ng build --prod
command which makes production ready build in separate dist
…