Skip to content

Generate(component): Does not default to SCSS when specified in .angular-cli.json #7624

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

Closed
timdoes opened this issue Sep 8, 2017 · 28 comments · Fixed by #7648
Closed

Generate(component): Does not default to SCSS when specified in .angular-cli.json #7624

timdoes opened this issue Sep 8, 2017 · 28 comments · Fixed by #7648

Comments

@timdoes
Copy link

timdoes commented Sep 8, 2017

Bug Report or Feature Request (mark with an x)

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

Versions.

@angular/cli: 1.4.0
node: 8.4.0
os: darwin x64
@angular/animations: 4.4.0-RC.0
@angular/cdk: 2.0.0-beta.8
@angular/common: 4.4.0-RC.0
@angular/compiler: 4.4.0-RC.0
@angular/core: 4.4.0-RC.0
@angular/flex-layout: 2.0.0-beta.9
@angular/forms: 4.4.0-RC.0
@angular/http: 4.4.0-RC.0
@angular/material: 2.0.0-beta.8
@angular/platform-browser: 4.4.0-RC.0
@angular/platform-browser-dynamic: 4.4.0-RC.0
@angular/router: 4.4.0-RC.0
@angular/cli: 1.4.0
@angular/compiler-cli: 4.4.0-RC.0
@angular/language-service: 4.4.0-RC.0
@angular/service-worker: 1.0.0-beta.16
typescript: 2.5.2

Repro steps.

Run ng g c foo

The log given by the failure.

No failure

Desired functionality.

Result: foo.component.css
Expected Result: foo.component.scss

Mention any other details that might be useful.

.angular-cli.json Example:

"defaults": {
  "styleExt": "scss",
},
@tieppt
Copy link

tieppt commented Sep 8, 2017

I face same problem

@lubkoKuzenko
Copy link

You can use flag ng g c foo --style=scss

@frizar
Copy link

frizar commented Sep 8, 2017

You can use flag ng g c foo --style=scss

But why is not documented?
https://github.com/angular/angular-cli/blob/master/docs/documentation/generate/component.md
And why styleExt: scss doesn't work?

@timdoes
Copy link
Author

timdoes commented Sep 8, 2017

I also just noticed that my specified default "prefix" is not working either.

@lubkoKuzenko You are correct, the individual flags still work but this bug report is for the .angular-cli.json file defaults not working.

@rafaelss95
Copy link

I just faced the same problem. It was working with 1.3.2.

It should supposed to be fixed in #7430, but the problem persists.

@zackarychapple
Copy link
Contributor

Experiencing this with 1.4.1 as well.

@bjornharvold
Copy link

Seeing this with 1.4.1 as well. Cheers.

@timdoes
Copy link
Author

timdoes commented Sep 14, 2017

I see that the app prefix is now being generated in v1.4.2 via bc58afe #7522 but the styleExt default is still not working.

@marekdon
Copy link

Same problem with 1.4.2

@garysui
Copy link

garysui commented Apr 12, 2018

I have the same problem with 6.0.0-rc.3

@SvenBudak
Copy link

Same problem with 6.0.3

@LuizAsFight
Copy link

Same problem with 6.0.2

@Reboog711
Copy link

Reboog711 commented Jun 27, 2018

Same problem with 6.0.1 .

My solution was to use the styleext command line argument when generating a component:

ng generate component dir/component-name --project=my-project --styleext=scss

A bunch of other links said to use a style command argument, but that didn't work for me, I assume because the argument changed when it finally got documented, or as part of the move from .angular-cli.json to angular.json.

@AhmedYousseff
Copy link

"schematics": {
"@schematics/angular:component": {
"spec": false,
"styleext": "scss"
},
instead of
"schematics": {
"@schematics/angular:component": {
"spec": false,
"styleExt": "scss"
}

@DmitriyIvanko
Copy link

Maybe I'm wrong. But I do not understand why this bug is closed. It definitely does not work in the latest version (Angular CLI 6.0.3).

@scott-erdmann
Copy link

Agreed, I am having the same issue with Angular 6.

@dc-m
Copy link

dc-m commented Aug 9, 2018

I'm also having this issue:
node: 10.8.0
npm: 6.2.0
angular: 6.0.2
angular/[email protected]

@Jrb1x
Copy link

Jrb1x commented Aug 9, 2018

Also having this issue on Angular 6. ng g c test-component --style=scss also doesn't work.

@Reboog711
Copy link

@Jrb1x Use --styleext=scss instead of --style=scss,

@WizardPC
Copy link

Same issue on a totally new project.

I use "ng new my-app --style=scss" and it's works (generate styles.scss for exemple), but "ng g c my-component" generate an .css

@DmitriyIvanko
Copy link

DmitriyIvanko commented Dec 10, 2018

When I use this one: http://prntscr.com/lt11a8 (I use ngrx also)
Problem has been solved

@hhmultimediallc
Copy link

hhmultimediallc commented Mar 13, 2019

I would really love to see the ng generate respect:

"schematics": {
":component": {
"styleext": "scss"
}

Seems like a simple feature to implement and one that would be consistent with user expectations for a product of this quality.

@ming0627
Copy link

In angular.json, set "schematics" as below to default scss when generate new component

"schematics": { "@schematics/angular:component": { "style": "scss" } }

@martinfletcher
Copy link

martinfletcher commented Apr 30, 2019

@ming0627 I have this already in my angular.json (CLI Version: 7.3.8), and it is being ignored...

UPDATE: It looks like its not respecting the schematic when you do not specify the project

My workspace has 2 projects, 'my-app' and 'my-lib'

Running 'ng g c my-component' generates with default css file extension

Running 'ng g c my-component --project=my-app' generates with the schematic set scss file extension

@frizar
Copy link

frizar commented Apr 30, 2019

Still not fixed in 2019, LMAO...
Thanks to Evan we have Vue, and I forgot this Angular nightmare.

@rynop
Copy link

rynop commented May 1, 2019

Working fine for me on v7.3.8. If you run ng new test1 --style=scss you'll notice ng g component blah creates with .scss.

Here is the minimum angular.json I found that works:

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

@vijayakumar-psg587
Copy link

vijayakumar-psg587 commented Sep 5, 2019

@rynop Thank you so much . The change in the "schematics" in angular.json makes the angular-cli adhere to the rule atleast in angular 8

@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 Oct 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.