austinthedeveloper
austinthedeveloper

Reputation: 2601

Setting Angular CLI generate defaults

All of my components follow the same structure:

ng g component componentName --skip-import --s true

Those two flags will always be used when generating a component. I would like to be able to this without defining the flags every time:

ng g component componentName

I'm having a hard time figuring out if there is a place to configure generate defaults or if I need to create my own schema. Has anyone else tried doing this before?

I've tried looking at the Angular Docs, mainly for generate and config(https://angular.io/cli/config) but it's unclear if I can do this.

Upvotes: 6

Views: 2539

Answers (1)

ABOS
ABOS

Reputation: 3821

You can try something like,

ng config schematics.@schematics/angular.component.inlineTemplate true

Adding -g to apply this globally.

You can also specify it in angular.json in your project settings,

"schematics": {
 "@schematics/angular": {
   "component": {
     "inlineTemplate": true
   }
 }
}

The local settings will override global settings, if exists.

Upvotes: 8

Related Questions