Full answer
An Angular workspace is a folder with one or more projects. The file angular.json is the CLI's map of the workspace.
Top level keys:
projects: one entry per application or library. Each hasroot,sourceRoot,prefix(the component selector prefix,appby default), andarchitect(the targets).schematics: defaults forng generate, for example making components useOnPush, or skipping tests.cli: workspace settings such as the package manager and analytics.
Inside a project, architect lists targets. A target has a builder and options:
builduses@angular/build:application(esbuild and Vite). Options includebrowser(the main entry file),tsConfig,assets,styles,polyfills,outputModeandssr.serveuses@angular/build:dev-server, and takes abuildTargetfrom the configuration.testuses@angular/build:karma(other test builders can be added).extract-i18n,lint, and others when added.
Configurations are named sets of option overrides. By default production turns on optimisation, hashing and budgets, and development turns off optimisation and enables source maps. defaultConfiguration chooses the one used when you do not pass --configuration. Run ng build --configuration development.
Other files: tsconfig.json (shared compiler options), tsconfig.app.json and tsconfig.spec.json (per target), package.json, and .editorconfig.
You can read and change options with ng config, and many generators edit angular.json for you. Commit this file, and keep changes small and reviewed, because it controls the build.
// file: angular.excerpt.json
{
"projects": {
"school-app": {
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular/build:application",
"options": { "browser": "src/main.ts", "tsConfig": "tsconfig.app.json", "styles": ["src/styles.css"] },
"configurations": {
"production": { "outputHashing": "all", "budgets": [{ "type": "initial", "maximumError": "1MB" }] },
"staging": { "outputHashing": "all", "fileReplacements": [{ "replace": "src/env.ts", "with": "src/env.staging.ts" }] },
"development": { "optimization": false, "sourceMap": true }
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular/build:dev-server",
"configurations": {
"development": { "buildTarget": "school-app:build:development" }
},
"defaultConfiguration": "development"
}
}
}
}
}Angular 20.3. The excerpt follows the structure of the file that Angular CLI 20 generates (builder names and the production and development configurations match the project used for testing here), shortened, with an added staging configuration. It is a data file, not executed.
Key points
- `angular.json` lists projects, and each project has targets with a builder and options.
- Configurations (`production`, `development`) override options. `defaultConfiguration` picks one.
- `schematics` sets defaults for `ng generate`.
- Per-target tsconfig files extend the root `tsconfig.json`.
Common mistakes
- Editing production behaviour by changing base options, instead of the production configuration.
- Forgetting that `--configuration` affects the target you run.
- Not committing `angular.json` changes made by generators.
Follow-ups
- How would you add a staging configuration?
- What does `ng add` change in this file?
- How do multiple projects in one workspace share code?
Tips
- Describe the structure: project, target, builder, configuration.
- Name the default builder for build and serve.
- Mention how to add a configuration.
Evaluation rubric
- Explains projects, targets, builders, options and configurations.
- Knows the default builder names.
- Mentions related tsconfig files.