Thursday, 24 January 2019

Custom project-level templates for angular components generated via angular-cli

How do I add custom angular component schematics to existing project?

I would like to have e.g. my-page component templates that will replicate existing \node_modules\@schematics\angular\component\ files but with edited templates.

I expect it to be achievable through angular-cli e.g. ng g my-page pagename command with schematics attribute.

Currently I modified code for existing agular's schematics under \node_modules\ so this works fine for me (until next package installation) but I would like to share this with the team so everyone will use predefined templates that will be stored in e.g. src\team-schematics\.

How do I achieve this?

I tried to create new schematic via schematics schematic --name my-schematic, copied angular schematic into \ClientApp\src\app\my-schematic\\ and trying to launch $ ng generate my-page --collection \ClientApp\src\app\my-schematic but no luck as of now:

Error: Could not find module "\\ClientApp\\src\\app\\my-schematic\\" from "C:\\Users\\xxx\\Projects\\yyy



from Custom project-level templates for angular components generated via angular-cli

No comments:

Post a Comment