Angular CLI v8.0.0 brought us a stable CLI Builders API, which allows you to customize, replace, or even create new CLI commands

Now the most popular builder for customizing the webpack configuration is  @angular-builders/custom-webpack. If you look at the source code of all the builders supplied with the package, you will see very compact solutions that do not exceed 30 lines of code.

Maybe make your own?

Challenge Accepted!

This material assumes that you are already familiar with the Angular and Angular CLI, you know what rxjs is and how to live with it, and you are also ready to read 50 lines of code.

So what exactly are these builders?

Builder is just a function that can be called using the Angular CLI. It is called with two parameters:

  1. JSON-like configuration object
  2. BuilderContext — an object that provides access, for example, to the logger.

A function can be either synchronous or asynchronous. As a bonus, you can return Observable. But in any case, both Promise and Observable should emit BuilderOutput.

This function, packaged in a certain way in the npm package, can be used to configure such CLI commands as buildtestlintdeploy, and any other from the architect section of the angular.json configuration file.

#angular #angular cli

How to Create your own Angular CLI Builder
10.90 GEEK