Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing default folder for components in angular-cli

Currently, the Angular CLI creates a new component by default in the app/{componentName}/ folder.

Is it possible to configure such that the cli will instead generate new component folders in app/components/{componentName}/ folder?

I tried messing around with some variables in the angular-cli.json but with no luck.

like image 353
Carven Avatar asked Jul 06 '16 13:07

Carven


1 Answers

There is nothing like that in place in the CLI for a persistent value. The reason for this is that the style guide suggests not placing all like entities (i.e. components, services) in a grouped directory.

With that being said to achieve this you have two options...

  1. Change the directory of your command line/terminal to app/components/ and generate from there. The CLI will know your current directory and create relative to that directory
  2. When you generate each component from the root of your project (or src dir) you can specify ng generate component components/foo which will include "components" in the path of where the component is generated.
like image 82
Brocco Avatar answered Oct 06 '22 00:10

Brocco