| name | angular-tooling |
| description | Use Angular CLI and development tools effectively in Angular v20+ projects. Use for project setup, code generation, building, testing, and configuration. Triggers on creating new projects, generating components/services/modules, configuring builds, running tests, or optimizing production builds. Don't use for Nx workspace commands, custom Webpack configurations, or non-Angular CLI build systems like Vite standalone or esbuild direct usage. |
Angular Tooling
Use Angular CLI and development tools for efficient Angular v20+ development.
Project Setup
Create New Project
ng new my-app
ng new my-app --style=scss --routing --ssr=false
ng new my-app --skip-tests
ng new my-app --minimal --inline-style --inline-template
Project Structure
my-app/
āāā src/
ā āāā app/
ā ā āāā app.component.ts
ā ā āāā app.config.ts
ā ā āāā app.routes.ts
ā āāā index.html
ā āāā main.ts
ā āāā styles.scss
āāā public/ # Static assets
āāā angular.json # CLI configuration
āāā package.json
āāā tsconfig.json
āāā tsconfig.app.json
Code Generation
Components
ng generate component features/user-profile
ng g c features/user-profile
ng g c shared/button --inline-template --inline-style
ng g c features/dashboard --skip-tests
ng g c features/settings --change-detection=OnPush
ng g c shared/icon --flat
ng g c features/checkout --dry-run
Services
ng g service services/auth
ng g s services/user
ng g s services/api --skip-tests
Other Schematics
ng g directive directives/highlight
ng g d directives/tooltip
ng g pipe pipes/truncate
ng g p pipes/date-format
ng g guard guards/auth
ng g interceptor interceptors/auth
ng g interface models/user
ng g enum models/status
ng g class models/product
Generate with Path Alias
ng g c @features/products/product-list
ng g c @shared/ui/button
Development Server
ng serve
ng s
ng serve --port 4201
ng serve --open
ng serve --host 0.0.0.0
ng serve --configuration=production
ng serve --ssl --ssl-key ./ssl/key.pem --ssl-cert ./ssl/cert.pem
Building
Development Build
ng build
Production Build
ng build --configuration=production
ng build -c production
ng build -c production --source-map=false
ng build -c production --named-chunks
Build Output
dist/my-app/
āāā browser/
ā āāā index.html
ā āāā main-[hash].js
ā āāā polyfills-[hash].js
ā āāā styles-[hash].css
āāā server/ # If SSR enabled
āāā main.js
Testing
Unit Tests
ng test
ng t
ng test --watch=false --browsers=ChromeHeadless
ng test --code-coverage
ng test --include=**/user.service.spec.ts
E2E Tests
ng e2e
Linting
ng lint
ng lint --fix
Configuration
angular.json Key Sections
{
"projects": {
"my-app": {
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/my-app",
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "tsconfig.app.json",
"assets": ["{ \"glob\": \"**/*\", \"input\": \"public\" }"],
"styles": ["src/styles.scss"],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kB",
"maximumError": "1MB"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
}
}
}
}
}
}
Environment Configuration
export const environment = {
production: false,
apiUrl: 'http://localhost:3000/api',
};
export const environment = {
production: true,
apiUrl: 'https://api.example.com',
};
Configure in angular.json:
{
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
}
Adding Libraries
Angular Libraries
ng add @angular/material
ng add @angular/pwa
ng add @angular/ssr
ng add @angular/localize
Third-Party Libraries
npm install @ngrx/signals
ng add @ngrx/store
Update Angular
ng update
ng update @angular/core @angular/cli
ng update --all
ng update @angular/core @angular/cli --force
Performance Analysis
ng build -c production --stats-json
npx esbuild-visualizer --metadata dist/my-app/browser/stats.json --open
Caching
{
"cli": {
"cache": {
"enabled": true,
"path": ".angular/cache",
"environment": "all"
}
}
}
rm -rf .angular/cache
For advanced configuration, see references/tooling-patterns.md.