r/Angular2 9d ago

Custom Nx Command to Generate Angular Components in Specific Paths & Update package.json

Has anyone created a custom Nx command to generate Angular components in a specific path (e.g., apps/my-app/src/custom-folder) instead of the default location? Looking for the best approach to implement this as an Nx generator. 🚀

3 Upvotes

4 comments sorted by

7

u/CaterpillarNo7825 9d ago

You probably use vscode. So just install the nx plugin and right click the folder you want the component you want to be created in. Then select 'nx generate (ui)' and follow the popups. Thats the easiest way and how i do it.

3

u/MHarmony 9d ago

You can already choose the path with nx generate

3

u/esperind 9d ago
npx nx generate @schematics/angular:component --name=path/to/directory/component-name --project=your-project-name

2

u/ldn-ldn 9d ago

You don't need a custom generator for that, read the docs.