Skip to main content
Flox Blog Beginner's Guide for Web Developers. 60% Off in Website Design & Development click here.

Angular 8 Folder Structure Full Guide.

Angular workspace structure configuration files.

In this article we will study about angular folder structure. In the development of applications in the context of an Angular workspace. A workspace holds the files for one or more projects. A project is the set of files that constitute a standalone application or a shareable library for you.

The Angular CLI ng new command creates a workspace.

ng new <project-name>

When you run this command in the terminal, the CLI installs the needed Angular npm packages and other dependencies in a new workspace, with a root-level application named project-name. The workspace root folder contains various support and configuration files, and a README file with generated descriptive text that you can customize on your own.

By default, ng new designs an initial skeleton application at the root level of the workspace, along with its end-to-end tests. The skeleton is for a simple Welcome page application that is ready to run and easy to change. The root-level application has the same name as the workspace, and the source files reside in the src/ subfolder of the workspace.

This default mode is suitable for a typical “multi-repo” development style where each application resides in its workspace. Beginners and intermediate users are encouraged to use ng new to create a separate workspace for each application.

Angular also supports workspaces with multiple projects. This type of development environment is becoming for advanced users who are developing shareable libraries, and for enterprises that use a “monorepo” development style, with a single repository and global arrangement for all Angular projects.

To set up a monorepo workspace, you should skip the building the root application. See Setting up for a multi-project workspace below.

Angular 8 workspace structure configuration files.

.editorconfigConfiguration for code editors.
.gitignoreSpecifies intentionally untracked files that Git should be ignore.
README.mdIntroductory documentation for the root app.
angular.jsonCLI configuration defaults for all of projects in the workspace, including configuration options for build, serve, and test tools that the CLI uses, such as TSLint, Karma, and Protractor. For details, see Angular Workspace Configuration.
package.jsonConfigures 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. See npm documentation for details.
src/Source files for the root-level application project.
node_modules/Provides npm packages to the entire workspace. Workspace-wide node_modules dependencies are visible to all projects.
tsconfig.jsonDefault TypeScript configuration for projects in the workspace.
tslint.jsonDefault TSLint configuration for projects in the workspace.

Angular 8 Application project files

By default, the CLI command ng new my-app-name creates a workspace folder named “my-app-name” and generates a new application skeleton in an src/ folder at the top level of the workspace. A newly created application contains 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 application. This initial root-level application is the default app for CLI commands (unless you change the default after creating additional apps).

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.

For a single-application workspace, the src/ subfolder of the workspace contains the source files (application logic, data, and assets) for the root application. For a multi-project workspace, additional projects in the projects/ folder contain a project-name/src/ subfolder with the same structure.

Angular 8 Application source files

app/Contains the component files in which your application logic and data are defined.
assets/Contains image 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.
favicon.icoAn icon to use for this application 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 application. 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.

Inside the src/ folder, the app/ folder contains your project’s logic and data. Angular components, templates, and styles are go here.

app/app.component.tsDefines the logic for the app’s root component, named AppComponent. The view associated with this root component becomes the root of the view hierarchy as you add components and services to your application.
app/app.component.htmlDefines the HTML template associated with the root AppComponent.
app/app.component.cssDefines the base CSS stylesheet for the root AppComponent.
app/app.component.spec.tsDefines a unit test for the root AppComponent.
app/app.module.tsDefines the root module, named AppModule, that tells Angular how to assemble the application. Initially declares only the AppComponent. As you add more components to the app, they must be declared here.

Angular 8 Application configuration files

The application-specific configuration files for the root application remain at the workspace root level. For a multi-project workspace, project-specific configuration files are in the project root, under projects/project-name/.

Project-specific TypeScript configuration files inherit from the workspace-wide tsconfig.json, and project-specific TSLint configuration files inherit from the workspace-wide tslint.json.

browserslistConfigures sharing of target browsers and Node.js versions among various front-end tools. See Browserslist on GitHub for more information.
karma.conf.jsApplication-specific Karma configuration. TypeScript configuration, including TypeScript and Angular template compiler options. See TypeScript Configuration.
tsconfig.spec.jsonTypeScript configuration for the application tests. See TypeScript Configuration.
tslint.jsonApplication-specific TSLint configuration.

Learn full details:

Leave a Reply

1 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
1 Comment authors
James Recent comment authors
newest oldest most voted
Notify of

Great post ! It is really informative and helpful . Thank you so much