HI WELCOME TO Sirees

Angular CLI project structure - 1

Leave a Comment

In this video we will discuss the Angular project structure. I have split this into 2 videos. In this video, we will discuss all the files and folders in the Angular project, except the "src" folder and it's contents. In our next video we will discuss the "src" folder and it's contents.


One of the easiest ways to create a working angular project, is by using the Angular CLI. The following Angular CLI command creates a working Angular Project out of the box
ng new AngularProject

The image below shows the Angular project in Visual Studio Code.

angular cli project structure

As you can see there are several files in the project. The table below shows the purpose of each file/folder.

File / FolderPurpose
package.jsonThis file contains the packages to build and run our application. It contains two sets of packages, dependencies and devDependencies. The dependencies are essential for running the application. The devDependencies are only required to develop the application. These packages are installed into the node_modules folder by the Node Package Manager (npm), when npm install commaned is excuted. You can also add your own custom scripts here.

"scripts" property in package.json file contains the useful npm commands. Notice we have "start": "ng serve". This means when we execute npm start it executes ng serve which builds and starts the server. In addition if you also want to launch the browser and open the application
CHANGE "start": "ng serve" TO "start": "ng serve --open"
node_modulesThe packages specified in package.json file are installed into this folder when we run npm install command
e2e FolderContains end-to-end tests and their configuration files. We will discuss end-to-end tests in our upcoming videos
.angular-cli.jsonThis is the Angular CLI configuration file. We discussed the use of this file in our previous video.
.editorconfigConfiguration file for Visual Studio Code. The settings in this file let you set certain code style guidelines. For example what indent_style do you want - spaces or tabs and what should be the indent size etc. You can share this editorconfig file with other developers to maintain consistent coding styles. To read more about editor configuration please visit http://editorconfig.org
.gitignoreThis file is used to determine files and folders you don't want to check in to source control. For example one of the folders we do not want to check in to source control is /dist folder which is auto generated when we build the application. So this folder is listed in this file. So, all the files and folders listed in this file are ignored, when a change set is checked in to source control.
karma.conf.jsKarma is the unit test runner for angular applications. As the name implies, karma.conf.js is the configuration file for Karma.
protractor.conf.jsProtractor is an end-to-end test framework for Angular applications. As the name implies, protractor.conf.js is the configuration file for Protractor.
README.mdThis is a README file which contains the commonly used Angular CLI commands out of the box. You may enhance it with your own project documentation so that anyone checking out the repo knows the commands to use to build, run and test your app.
tsconfig.jsonThis is the TypeScript compiler configuration file. This file has several TypeScript compiler configuration settings. For example, to compile TypeScript to JavaScript on saving a TypeScript file set compileOnSave setting to true. If you do not want .map files to be generated, set sourceMap to false. .map files are used for debugging your application.
tslint.jsonAngular has a linting tool that checks our TypeScript code for programmatic and stylistic errors as well as non-adherence to coding standards and conventions. tslint.json is the configuration file for linting. We will discuss the settings in this file when we discuss linting in our upcoming videos.

In our next video we will discuss the "src" folder and it's contents.

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.