Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng generate does not respect defaults.styleExt settings #7644

Closed
onwsk8r opened this issue Sep 10, 2017 · 11 comments
Closed

ng generate does not respect defaults.styleExt settings #7644

onwsk8r opened this issue Sep 10, 2017 · 11 comments
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity3: broken

Comments

@onwsk8r
Copy link

onwsk8r commented Sep 10, 2017

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

Versions.

> ng --version
@angular/cli: 1.4.1
node: 6.11.3
os: linux x64
@angular/animations: 4.3.6
@angular/common: 4.3.6
@angular/compiler: 4.3.6
@angular/core: 4.3.6
@angular/forms: 4.3.6
@angular/http: 4.3.6
@angular/platform-browser: 4.3.6
@angular/platform-browser-dynamic: 4.3.6
@angular/router: 4.3.6
@angular/cli: 1.4.1
@angular/compiler-cli: 4.3.6
@angular/language-service: 4.3.6
typescript: 2.3.4
> npm --version
3.10.10

Repro steps.

After setting the default....

> ng set --global defaults.styleExt=scss
> grep styleExt ~/angular-cli.json
    "styleExt": "scss"

When I make a new project...

> ng new my_proj && cd my_proj
...
> grep styleExt ./.angular-cli.json
    "styleExt": "scss", 

I have a file called app.component.scss with the correct styleUrl in app.component.ts.

However, when I ng g component my-awesome-component, I end up with my-awesome.component.css and the equivalent styleUrl in the Typescript file.

Desired functionality.

I would like it to respect the settings in .angular-cli.json like ng new does.

@alaindeurveilher
Copy link

It is not only the styleExt property, but also the prefix property which is ignored.
in my .angular-cli.json I have

{
  "apps": [
    {
      "prefix": "ts",
    }
  ],
  "defaults": {
    "styleExt": "scss",
    "component": {}
  }
}
"

but when generating a new component ng g +my-module/new-component I end up with a .css file instead of a .scss as already reported, but also the component selector is app-new-component instead of ts-new-component

I think that this is a serious regression compared to v1.3.2

@bboehm86
Copy link

Actually all defaults are ignored in the .angular-cli.json file. If you use the options directly in the command line everything still works file.

@VirajNimbalkar
Copy link

Same with me, I raised issue over SO for this, Here is link , https://stackoverflow.com/questions/46139997/angular-cli-1-4-1-ng-always-generate-spec-file-and-css-even-default-prefix-is

I thought , its only with me, but seems CLI team broke things very seriously here. I hope by downgrading it solve temporary.

@shmool
Copy link

shmool commented Sep 10, 2017

The style extension issue was already reported here: #7624

@Brocco I believe there is a problem with the schematics library.
I found two troublesome commits, tested with the command ng g c test:

128187e
Problems that started here:

  1. default style extension ignored
  2. alias c doesn't work, using component does.

884385e

  1. alias c came back to life
  2. default style extension is still ignored
  3. default inlineTemplate is ignored starting from this commit

Hope this helps! :)

@rafaelss95
Copy link

Dupe of #7624

@onwsk8r
Copy link
Author

onwsk8r commented Sep 11, 2017

Even though this is a dupe I'm going to leave it open since #7647 will close this when it gets merged (and as of now, Travis is passing, so it just needs a review). And sorry for posting a dupe- I'm not sure how I missed 7624.

@JustDoItSascha
Copy link

JustDoItSascha commented Jun 19, 2018

Is this really still open?

@clydin clydin closed this as completed Jun 19, 2018
@chris31389
Copy link

This works

{
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "projects": {
        "my-app": {
            "root": "",
            "sourceRoot": "src",
            "projectType": "application",
            "prefix": "app",
            "schematics": {
                "@schematics/angular:component": {
                    "styleext": "scss"
                }
            },
            ...
       }
   }
}

@JosepAlacid
Copy link

JosepAlacid commented Apr 11, 2019

It's sad but on:

Angular CLI: 7.3.7
  Node: 10.14.1
  OS: win32 x64
  Angular: 7.2.11
  ... animations, common, compiler, compiler-cli, core, forms
  ... http, language-service, platform-browser
  ... platform-browser-dynamic, router, service-worker
  
  Package                           Version
  -----------------------------------------------------------
  @angular-devkit/architect         0.13.7
  @angular-devkit/build-angular     0.13.7
  @angular-devkit/build-optimizer   0.13.7
  @angular-devkit/build-webpack     0.13.7
  @angular-devkit/core              7.3.7
  @angular-devkit/schematics        7.3.7
  @angular/cdk                      7.3.6
  @angular/cli                      7.3.7
  @angular/flex-layout              7.0.0-beta.24
  @angular/material                 7.3.6
  @angular/pwa                      0.13.7
  @ngtools/webpack                  7.3.7
  @schematics/angular               7.3.7
  @schematics/update                0.13.7
  rxjs                              6.4.0
  typescript                        3.2.4
  webpack                           4.29.0

ng generate component is still ignoring default settings on angular.json:

      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "ids",
      "schematics": {
        "@schematics/angular:component": {
          "inlineStyle": false,
          "inlineTemplate": false,
          "spec": false,
          "styleext": "scss"
        }
      },

Actually it's only happening on "spec" and "styleext". Prefix and directories are working OK.

@JosepAlacid
Copy link

On Angular 8 , in my case, this issue is only happening after install @ngxs/schematics. Once this option is removed, ng g component is working fine again.
Hope this helps.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity3: broken
Projects
None yet
Development

No branches or pull requests