8

Prior to updating to Angular 9, my project was configured to use SCSS when the ng generate command was run, and indeed it did.

Much to my dismay, after running my first ng g c on Angular 9, it added a css file rather than a scss file.

The accepted answer to this does not appear to work any longer. My angular.json includes the following (as it has for the past two years):

  "schematics": {
    "@schematics/angular:component": {
      "styleext": "scss"
    }
  },

How do I fix this?

1
  • 3
    styleext is now deprecated, you should use style instead. Commented Apr 12, 2020 at 16:09

2 Answers 2

14

Please try like this.

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

"schematics": { "@schematics/angular:component": { "style": "scss" } }
Sign up to request clarification or add additional context in comments.

1 Comment

If it still doesn't work check if you have other schematics configured that overrule the angular default ones, like rxjs, ngxs, cypress, ... You need to use the appropriate package then, e.g. @cypress/schematic:component instead of @schematics/angular:component see also stackoverflow.com/a/57178153
8

I recently upgraded my Angular CLI to v12 and generated a new project. I opted to generate scss files for new components. After creating a component, I saw that css files were being generated, not scss files. I ran the below command and now when I generate a new component, the scss file is created and not css.

ng config schematics.@schematics/angular:component.style scss

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.