Angular Json Notes
Angular Json Notes
Angular Json Notes
json
Code :-
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"Budget_house_": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"standalone": false
},
"@schematics/angular:directive": {
"standalone": false
},
"@schematics/angular:pipe": {
"standalone": false
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/budget-house",
"allowedCommonJsDependencies": ["lodash"],
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets",
"src/environments"
],
"styles": [
"@angular/material/prebuilt-themes/deeppurple-amber.css",
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "5mb",
"maximumError": "6mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "5mb",
"maximumError": "6mb"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"proxyConfig": "proxy.conf.json"
},
"configurations": {
"production": {
"buildTarget": "Budget_house_:build:production"
},
"development": {
"buildTarget": "Budget_house_:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "Budget_house_:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"assets": [
"src/favicon.ico",
"src/assets",
"src/environments"
],
"styles": [
"@angular/material/prebuilt-themes/deeppurple-amber.css",
"src/styles.css"
],
"scripts": []
}
}
}
}
},
"cli": {
"analytics": "52b3c44b-5b9d-47ef-a86d-069f22588c2b"
}
}
Explanation :-
- The angular.json file is a configuration file used by the Angular CLI (Command Line Interface) to
define various settings and options for an Angular project. It provides a centralized location to
manage project configuration, including build settings, file paths, and third-party library
integrations.
- This file is generated automatically when you create a new Angular project using the Angular
CLI (Command Line Interface). It is a JSON file that contains various configuration settings for
your Angular project.
-The angular.json file includes settings related to project structure, build options, assets, styles,
scripts, and more.
-"projects": {
"Budget_house_": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"standalone": false
},
"@schematics/angular:directive": {
"standalone": false
},
"@schematics/angular:pipe": {
"standalone": false
}
},
explaination of this part :-
• This part of the angular.json file is under the "projects" key and defines the configuration for a
specific project named "Budget_house_".
• "projectType": Specifies the type of project. In this case, it's set to "application", indicating that
the project is an Angular application.
• schematics": They are essentially code templates and generators that allow you to scaffold out
common parts of your Angular application, such as components, services, modules, directives,
and more.
• - When you use the Angular CLI to generate components, services, or other parts of your
application, you are actually using Angular schematics under the hood. Angular provides a
set of built-in schematics that you can use out of the box, and you can also create custom
schematics to meet your unique requirements.
• For example, when you run ng generate component my-component, the Angular CLI uses
the @schematics/angular:component schematic to generate the necessary files and code for
a new component in your project.
-"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/budget-house",
"allowedCommonJsDependencies": ["lodash"],
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets",
"src/environments"
],
"styles": [
"@angular/material/prebuilt-themes/deeppurple-amber.css",
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
"type": "initial",
"maximumWarning": "5mb",
"maximumError": "6mb"
},
"type": "anyComponentStyle",
"maximumWarning": "5mb",
"maximumError": "6mb"
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
},
"defaultConfiguration": "production"
},
-"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"proxyConfig": "proxy.conf.json"
},
"configurations": {
"production": {
"buildTarget": "Budget_house_:build:production"
},
"development": {
"buildTarget": "Budget_house_:build:development"
}
},
"defaultConfiguration": "development"
},
explanation of code :-
• This section of the angular.json file is responsible for configuring the development server (ng
serve) for your Angular project.
• builder: Specifies the builder to use for serving the application. In this case, it's "@angular-
devkit/build-angular:dev-server", which is a builder provided by Angular for running a
development server.
• proxyConfig: Specifies the path to a proxy configuration file. This file (proxy.conf.json) can be
used to configure proxy settings for the development server, allowing you to proxy requests to
backend APIs during development to avoid CORS issues.
• buildTarget: Specifies the target to use for building the application in production. In this case, it's
set to "Budget_house_:build:production", indicating that the production build configuration
defined earlier ("Budget_house_:build") should be used.
• buildTarget: Specifies the target to use for building the application in development. Similarly, it's
set to "Budget_house_:build:development", indicating that the development build configuration
should be used.
• defaultConfiguration: Specifies the default configuration to use when serving the application.
Here, it's set to "development", meaning that when you run ng serve without specifying a
configuration, the development configuration will be used by default.
-"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "Budget_house_:build"
},
explanation of code :-
• extract-i18n: This section specifies the configuration for extracting internationalization messages.
• builder: Specifies the builder to use for extracting i18n messages. In this case, it's "@angular-
devkit/build-angular:extract-i18n". This builder is responsible for extracting translatable
messages from the application's templates and TypeScript files.
• buildTarget: Specifies the target to use for building the application before extracting i18n
messages. Here, it's set to "Budget_house_:build". This indicates that the build configuration
named "Budget_house_:build" should be used for building the application before extracting i18n
messages.
-"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"assets": [
"src/favicon.ico",
"src/assets",
"src/environments"
],
"styles": [
"@angular/material/prebuilt-themes/deeppurple-amber.css",
"src/styles.css"
],
"scripts": []
explanation of code :-
• This section of the angular.json file configures the testing setup for your Angular project using
Karma, a popular test runner for JavaScript.
• test: Specifies the configuration for running tests in the Angular project.
• builder: Specifies the builder to use for running tests. In this case, it's "@angular-devkit/build-
angular:karma". This builder is responsible for setting up and executing the tests using the Karma
test runner.
• polyfills: Specifies polyfills needed for testing. Polyfills are additional scripts that provide
functionality not supported by all browsers. Here, "zone.js" and "zone.js/testing" are included.
These polyfills help with asynchronous operations and testing-specific functionality.
• tsConfig: Specifies the TypeScript configuration file to use for compiling the test files. In this case,
it's set to "tsconfig.spec.json", which is typically a specialized TypeScript configuration file for
testing.
• assets: Specifies static assets needed for testing. This can include files like images, fonts, or JSON
files. Here, "src/favicon.ico", "src/assets", and "src/environments" are specified as asset paths.
• styles: Specifies CSS or SCSS files needed for testing. Similar to the assets, these files are included
in the testing environment to ensure that the tests run in a similar environment to the
application itself. Here, "@angular/material/prebuilt-themes/deeppurple-amber.css" and
"src/styles.css" are specified.
• scripts: Specifies additional JavaScript files needed for testing. In this case, it's an empty array,
indicating that no additional scripts are included specifically for testing.
-"cli": {
"analytics": "52b3c44b-5b9d-47ef-a86d-069f22588c2b"
explanation of code :-
• analytics: Specifies an analytics identifier. This identifier is typically used for tracking Angular CLI
usage. It allows the Angular team to gather information about how developers are using the CLI,
which can help them improve the tool in future releases.
• By default, the Angular CLI sends anonymous usage data to the Angular team to help improve
the CLI's performance and user experience. This data may include information such as CLI
commands used, project configurations, and error messages encountered. However, this feature
can be disabled if desired, either during project creation or by modifying the angular.json file
directly.