6

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.

5
  • 3
    something like ng config schematics.@schematics/angular.component.inlineTemplate true? Commented Jan 24, 2019 at 20:20
  • This is exactly what I was wanting. Post it as an answer and I'll accept it Commented Jan 24, 2019 at 20:31
  • 1
    As stated by @ABOS you can use that command, and look into more options to set here appdata/roaming/npm/node_modules/@angular/cli/lib/config/schema.json. Commented Jan 24, 2019 at 20:32
  • @ABOS, it sets the value for one project, not as a global setting.. Commented Jan 24, 2019 at 20:34
  • @SachinGupta I only wanted it on a project level. I work on multiple projects and not all of them are configured the same. Commented Jan 24, 2019 at 20:35

1 Answer 1

8

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.