angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Feature: support command-line args for templates and stylesheets

Open d-koppenhagen opened this issue 10 years ago • 6 comments

It would be nice to have some command line parameters for ng g my-component. E.g. to specify if a separate .html-file should should be created or maybe inline-HTML is enough. Here some suggestions:

ng g component my-component arg

arg description
--template use template: 'my-component works' instead of templateUrl: 'path/to/file.html'
--styles use styles: [] instead of styleUrls: ['path/to/file.css']
--no-style no styles: [] or styleUrls: ['path/to/file.css'] in the component

d-koppenhagen avatar Mar 26 '16 12:03 d-koppenhagen

I believe the build process is going to eventually take the URL's and replace them with the inlined content from the files. @hansl am I remembering right?

zackarychapple avatar Mar 28 '16 12:03 zackarychapple

I like this idea, except for the usability aspect. I don't like the idea of having to specify these arguments with every generated component (for consistency in an application).

I think settings like this can be handled in 2 ways.

  • Add settings through the settings file angular-cli.json
  • A component style add-on

At this point neither are fully ready for use, but I think at this time the CLI would be best served by waiting for one of those two mechanisms to be in place rather than requiring developers to supply the flags every time a component was generated.

Brocco avatar Mar 28 '16 13:03 Brocco

I like settings things in the angular-cli.json works well but I still think there should be provided command line args to overwrite those if needed for a one off.

deebloo avatar Mar 31 '16 12:03 deebloo

I agree with @deebloo . Configure this globally in angular-cli.json makes sense (e.g. if I want to use template instead of templateUrl in my whole project). But in some cases (e.g. if the template contains only <router-outlet></router-outlet> I may just want to use the inline-template in one of many components.

d-koppenhagen avatar Apr 06 '16 05:04 d-koppenhagen

Late to this, but... Using the "--it" and "--is" flags accomplish this goal.

joedope avatar Apr 10 '17 17:04 joedope

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.