Skip to content

Have ng g c [name] generate inline-template and inline-style automatically from config #6570

Closed

Description

@gioragutt

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [X] feature request

Versions.

master

Repro steps.

ng new delete-me-quickly
cd delete-me-quickly/src/app
ng g c hello
cd hello && ls
Contains html and css files, instead of them being inline.

The log given by the failure.

Desired functionality.

If the functionality is specified in ng new using -is or -it, a respective setting should be saved in .angular-cli.json and stick in generation of new Components and/or Directives.

Mention any other details that might be useful.

I came up with it during research I'm doing for #6480, where I'm updating the documentation for ng new.

I would like to further contribute by adding this feature myself and PRing it. Would that be acceptable? Is this feature even discussed? I would very much like to contribute in the cli, especially something that is more code than docs.

EDIT

After additional research, I did find that .angular-cli.json has such configuration, as specified here:

    /* blueprints/component/index.ts */
    options.inlineStyle = options.inlineStyle !== undefined ?
      options.inlineStyle : CliConfig.getValue('defaults.component.inlineStyle');

    options.inlineTemplate = options.inlineTemplate !== undefined ?
      options.inlineTemplate : CliConfig.getValue('defaults.component.inlineTemplate');

But it is not set during ng new.

Activity

  1. changed the title [-]Have ng g c [name] generate inline-template and inline-style[/-] [+]Have ng g c [name] generate inline-template and inline-style automatically from config[/+] on Jun 3, 2017
  2. added
    featureLabel used to distinguish feature request from other issues
    on Jun 6, 2017
  3. filipesilva commented on Jun 6, 2017

    @filipesilva
    Contributor

    @Brocco WDYT?

  4. sumitarora commented on Jun 6, 2017

    @sumitarora
    Contributor

    @filipesilva @Brocco It's good option to have on the other side I think it should be on the component also as when creating small components which only are containers or have few lines would like to have those inline.

  5. gioragutt commented on Jun 6, 2017

    @gioragutt
    ContributorAuthor

    @sumitarora what you're talking about exists. My thought process behind this change is that if someone specifies in lines on new, I believe they want it for the entire app. If someone wants a particular component with inlines, the g c command accepts inlines already, and they are given priority over defaults, as you can see in the snippet above

  6. Brocco commented on Jun 6, 2017

    @Brocco
    Contributor

    To understand, you wish to make the change that when a user creates an app using --inline-template or --inline-style that the setting be persisted to .angular-cli.json for future generations for that app?

    Current state, just the app component will get inlined, no setting saved to .angular-cli.json

    Proposed: set the inline flag(s) when used during ng new

    Issue: What if the dev wants to only inline their app component as it typically is very light but not all subsequent components?

    Suggestion: Add new flags to clearly state the desire to have all components inlined...

    --inline-style-all (-isa)
    --inline-template-all (-ita)
    

    The result of using these flags would be to set it for the current run and set the value in angular-cli.json

    Thoughts?

  7. gioragutt commented on Jun 6, 2017

    @gioragutt
    ContributorAuthor

    @Brocco I like the suggestion. Also I think that the existing flags documentation should be updated to explain they only cause AppComponent to be inline.

  8. gioragutt commented on Jun 10, 2017

    @gioragutt
    ContributorAuthor

    @filipesilva @sumitarora @Brocco So it's agreed that -all is the right way to go? Can I go on and implement? Implementation would be an update to my existing PR #6571

  9. donoso-eth commented on Jul 28, 2017

    @donoso-eth

    @Brocco, @gioragutt I just gave some thoughts and in my opinion a good "logic" soluton would be:

    1- When creating a new project, a setting wiil be saved to .angular-cli.jsony
    2- This setting can be changed anytime by the dev in ng set defaults.inline="true/false"
    3- when the dev generates a component, pipe, etc.. the cli will generate according to the defaults inline unless he specifies otherwisse with the current "-is" flag or with one new flag to be created "-nis" no inline.
    4- If the dev specifies the "-is" or "-nis" this configuration will override the defaults but only for this component/pipe, etc.

    What do you think?

  10. gioragutt commented on Jul 28, 2017

    @gioragutt
    ContributorAuthor

    @ampgular this is how it works today. Except that it just doesn't save it in .angular-cli.json, which is what my PR changes. You can see in the generate command, that it checks both the setting in .angular-cli.json, and the setting from the command line arguments given in the command, giving priority to the command line argument setting.

  11. phamdt commented on Sep 7, 2017

    @phamdt

    +1

  12. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    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.

  13. locked and limited conversation to collaborators on Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

featureLabel used to distinguish feature request from other issues

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions