Skip to main content

What are Builders?

Builders are the underlying execution engine for Angular CLI commands. They are part of the Angular Architect API and define how commands like ng build, ng test, and ng serve actually work. Each builder is a function that performs a specific task according to a target configuration defined in angular.json.
Builders are similar to webpack plugins or Gulp tasks - they’re modular units that perform specific build operations.

Builder Architecture

The Angular CLI uses the Architect system to run builders:

Key Concepts

Target

A named builder configuration in angular.json (e.g., “build”, “test”)

Builder

The actual implementation that performs the work

Options

Configuration parameters passed to the builder

Configurations

Named option overrides (e.g., “production”, “development”)

Official Builders

Angular provides several official builders:

Application Builders

The modern application builder (Angular v17+) using esbuild and Vite.
Features:
  • Fast builds with esbuild
  • Improved development server
  • Better optimization
  • SSR/SSG support out of the box
Angular v17+ recommends using @angular/build:application for new projects.

Development Server Builders

@angular/build:dev-server

Development server for the application builder:
Key Options:
  • buildTarget: Which build configuration to serve
  • port: Development server port
  • host: Host address
  • ssl: Enable HTTPS
  • proxyConfig: API proxy configuration

Test Builder

@angular-devkit/build-angular:karma

Runs unit tests with Karma:
Options:
  • karmaConfig: Path to Karma configuration
  • watch: Watch files for changes
  • codeCoverage: Generate coverage reports
  • browsers: Browsers to run tests in
The Angular team uses Karma 6.4.0 for testing in the source repository.

Internationalization Builder

@angular/build:extract-i18n

Extracts i18n messages from templates:

Lint Builder

@angular/build:tslint

Runs TSLint on the project:
TSLint is deprecated. Consider migrating to ESLint with @angular-eslint.

Builder Options

Common Options

These options are available across multiple builders:
string | object
Where to write build output files
string
Hash output files for cache busting: none, all, media, bundles
string
Path to index.html file
string
Main browser entry point (for application builder)
string
Main entry point (for browser builder)
string[]
Polyfills to include
string
Path to TypeScript configuration file
boolean
default:"true"
Enable Ahead-of-Time compilation
array
Static assets to copy
array
Global stylesheets to include
array
Global scripts to include
boolean | object
Enable optimization (minification, tree-shaking)
boolean
Generate source maps
boolean
Use human-readable chunk names
boolean
Extract third-party licenses to separate file
array
Size budgets for application

Build Configurations

Configurations are named sets of option overrides:

Using Configurations


Custom Builders

You can create custom builders for specialized build tasks.

Creating a Custom Builder

1

Create Builder Package

2

Define Builder Schema

Create schema.json:
3

Implement Builder

4

Register Builder

Add to builders.json:
5

Use in angular.json

Running Custom Builder


Builder Context

Builders receive a BuilderContext with useful utilities:

File Replacements

Replace files during build based on configuration:
Useful for environment-specific configurations.

Build Optimization Strategies

Code Splitting

Tree Shaking

Enabled automatically with optimization:

Differential Loading

Generate separate bundles for modern and legacy browsers:

Performance Budgets

Set size limits to maintain performance:
Total size of initial bundle.

Proxy Configuration

Configure API proxying for development: proxy.conf.json:
angular.json:

Build Events

Builders emit events during execution:

Next Steps

Schematics

Create custom code generators

CLI Commands

Master all Angular CLI commands

Resources

Architect API

Official builder documentation

Builder Examples

Angular DevKit builders source