Search code examples
javascriptangularcode-generation

Can I create custom templates for sources generated by Angular CLI


When I execute the following command in an Angular 9 project to generate e.g. a component

$ ng generate component

I would like to customize the sources generated - in particular the unit and e2e test files.

Is there a mechanism for me to provide templates, or modify existing ones?

they should also be accessible to all team members on my project.

I am aware of yo generators, but I'd prefer to stick with ng.


Solution

  • They are called Schematics and there is an official documentation for it. You can find it here: https://angular.io/guide/schematics

    You can also find a lot of good guides around the Internet regarding this topic, i guess you were just missing the correct name to find the information :)