0

Is there any way to specify a default folder name in a configuration file like angular.json, so that all developers running the cli-command ng g c MyComponent --skipTests without folder name will create components in this preconfigured folder (e.g. MyFolder) by default?

This query holds the knowledge of How to generate components in a specific folder with angular-cli?

It is not a duplicate because the above question only answers how to specify the target folder in the command line call, and not how to preconfigure a default folder.

Suppose there are several developers, and all create a lot of components that should all be placed in one specific folder.

Instead of typing the folder every time in the commandline call, angular should use a default even if no folder is specified during the commandline call. That way, the developers do not need to remember to provide the MyFolder name all the time.

For example

ng g c MyFolder/MyComponent1 --skipTests
ng g c MyFolder/MyComponent2 --skipTests
ng g c MyFolder/MyComponent3 --skipTests
ng g c MyFolder/MyComponent4 --skipTests
ng g c MyFolder/MyComponent5 --skipTests
ng g c MyFolder/MyComponent6 --skipTests
ng g c MyFolder/MyComponent7 --skipTests

they should just be allowed to type:

ng g c MyComponent1 --skipTests
ng g c MyComponent2 --skipTests
ng g c MyComponent3 --skipTests
ng g c MyComponent4 --skipTests
ng g c MyComponent5 --skipTests
ng g c MyComponent6 --skipTests
ng g c MyComponent7 --skipTests

but the components should still be generated in MyFolder folder.

Risadinha
  • 16,058
  • 2
  • 88
  • 91
Ajay Nishad
  • 361
  • 1
  • 3
  • 10
  • I dont know why marked this query as duplicate of https://stackoverflow.com/questions/46851399/how-to-generate-components-in-a-specific-folder-with-angular-cli, though its not. – Ajay Nishad Mar 28 '19 at 06:39
  • Thanks @Risadinha for making the best edit. – Ajay Nishad Mar 28 '19 at 11:24
  • If you are using webpack, maybe this helps: https://medium.freecodecamp.org/how-to-configure-webpack-4-with-angular-7-a-complete-guide-9a23c879f471 – Risadinha Mar 28 '19 at 12:30
  • For now I am not using Webpack, well thanks for the suggestion. I will give it a try. – Ajay Nishad Mar 28 '19 at 18:29

0 Answers0