Skip to main content

Workspace and project file structure of Angular

A workspace can be defined as a collection of files for one or more projects. A collection of projects makes up a workspace.

A project is the set of files that comprise a standalone application, a library or package, or a set of end-to-end tests.

In the creation of an Angular application, the Angular CLI command `ng new <project_name>` gets us started. When we run this command, the CLI installs the necessary Angular npm packages and other dependencies in a new workspace, with a root folder named project_name.

It also creates the following workspace and starter project files:

  • An initial skeleton app project (in the src/ subfolder).
  • An end-to-end test project (in the e2e/ subfolder).
  • Related configuration files.

The initial app project contains a simple welcome app, ready to run.

In this tutorial, we will explore the Angular file structure and the functions of some of these configuration files.


Workspace files

The top level of the workspace contains a series of workspace-wide configuration files.

Workspace Configuration FilesPurpose of the configuration file
.editorconfigConfiguration for code editors.
.gitignoreSpecifies intentionally untracked files that Git should ignore.
angular.jsonCLI configuration defaults for all projects in the workspace, including configuration options for build, serve, and test tools 
that the CLI uses, such as TSLint, Karma, and Protractor.
node_modulesProvides npm packages to the entire workspace.
package.jsonConfigures and keeps track of npm package dependencies that are available to all projects in the workspace.
package-lock.jsonProvides version information for all packages installed into node_modules by the npm client. If you use the yarn client,
this file will be yarn.lock instead.
tsconfig.jsonDefault TypeScript configuration for applications in the workspace, including TypeScript and Angular template compiler options.
tslint.jsonDefault TSLint configuration for apps in the workspace.
README.mdIntroductory documentation for the application

Default app project files

The CLI command `ng new my-app` creates a workspace folder named "my-app" and generates a new app skeleton. This initial app is the default app for CLI commands (unless you change the default after creating additional apps).

A newly generated app contains the source files for a root module, with a root component and template. When the workspace file structure is in place, you can use the `ng generate command` on the command line to add functionality and data to the initial app.

Besides using the CLI on the command line, you can also use an interactive development environment like Angular Console, or manipulate files directly in the app's source folder and configuration files.

The src/ subfolder contains the source files (app logic, data, and assets), along with configuration files for the initial app. Workspace-wide node_modules dependencies are visible to this project.

Application Source and 
Configuration Files
Purpose of the configuration files
.app/Contains the component files in which your app logic and data are defined.
.assets/Contains image files and other asset files to be copied as-is when you build your application.
environments/Contains build configuration options for particular target environments. By default, there is an unnamed standard development environment and 
a production ("prod") environment. You can define additional target environment configurations.
browserslistConfigures sharing of target browsers and Node.js versions among various front-end tools.
favicon.icoAn icon to use for this app in the bookmark bar.
index.htmlThe main HTML page that is served when someone visits your site. The CLI automatically adds all JavaScript and CSS files when building your app,
so you typically don't need to add any <script> or<link> tags here manually.
main.tsThe main entry point for your app. Compiles the application with the JIT compiler and bootstraps the application's root module (AppModule) to run in the browser.
You can also use the AOT compiler without changing any code by appending the -–aot flag to the CLI build and serve commands.
polyfills.tsProvides polyfill scripts for browser support.
styles.sassLists CSS files that supply styles for a project. The extension reflects the style preprocessor you have configured for the project.
test.tsThe main entry point for your unit tests, with some Angular-specific configuration. You don't typically need to edit this file.
tsconfig.app.jsonInherits from the workspace-wide tsconfig.json file.
tsconfig.spec.jsonInherits from the workspace-wide tsconfig.json file.
tslint.jsonInherits from the workspace-wide tslint.json file.



Comments

Popular

JavaScript type hoisting with variable function Expression

JavaScript type hoisting with variable function Expression Hoisting is JavaScript default behavior to moving declaration on the top. Variable can be used before its declaration. To understand this, first we need to understand of hoist meaning, hoist means “raise(something) by means of ropes & pulleys”. now we can relate hoisting with JavaScript. JavaScript interpreter moves all declaration on the top at runtime. It is best practice to declare all variable at the top of their respective scopes. , JavaScript is loosely syntax language so it will not throw any error at runtime if the variable used before its declaration. But JavaScript does not allow variable used before its declaration in “use strict” mode. Example 1 In this example, we can see in a normal scenario, when y has declared & then used. in this case, it will give output 10 as excepted. <p id= "demo" ></p> <script> var y; //Declare y y = 10 ; ...

Building Block of Angular

The main building blocks for Angular are modules, components, templates, metadata, data binding, directives, services, and dependency injection. Below mentioned are the main building blocks of an Angular application: - Modules  group components logically within the project. Angular basically is a modular framework where every block of functionality is encapsulated within a module and exposed outside within the project as a service. There are two types of modules one is encapsulating block of function within a single component and the other is encapsulating block of function within single or group of components by providing exposure in a unified manner via an interface. Components  help in controlling UI block and also it provides data and logic. It represents a unique "View" and "View Model" in MVVM pattern or exactly like what Controllers do in Angular 1. The "V...

HTML Basic

HTML (Hypertext Markup Language) Basic What is HTML ? HTML invented by Tim Berners-Lee in 1990. HTML stands for hypertext markup language. Web browsers receive HTML documents from a web server or from local storage and render the documents into multimedia web pages .We can create web page with different elements like audio, video, image, tables, link, list & text etc, with CSS & JavaScript. version of HTML There are 6 version of HTML HTML Version Year HTML 1991 HTML 2.0 1995 HTML 3.2 1997 HTML 4.01 1999 XHTML 2000 HTML 5 2014 (Latest version) Latest version of HTML Latest version of html is HTML 5.0 , in latest version of html provided new tags for multimedia support. Now we are creating web page  index.html  How we can create Web page <!DOCTYPE html> < html > < head > < title > This is my First Web Page </ title > </ head > < body > < h1 > My First heading ...