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

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

Open timdoes opened this issue 9 years ago • 28 comments

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",
},

timdoes avatar Sep 08 '17 00:09 timdoes

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

DmitriyIvanko avatar Dec 10 '18 11:12 DmitriyIvanko

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.

hhmultimediallc avatar Mar 13 '19 05:03 hhmultimediallc

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

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

ming0627 avatar Apr 27 '19 16:04 ming0627

@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

martinfletcher avatar Apr 30 '19 08:04 martinfletcher

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

frizar avatar Apr 30 '19 09:04 frizar

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"
}

rynop avatar May 01 '19 15:05 rynop

@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

vijayakumar-psg587 avatar Sep 05 '19 11:09 vijayakumar-psg587

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.