angular-cli: Changing default styleExt to scss gives me Value cannot be found

I’ve made new project using angular-cli@6.0.2. I want to change defalt style file to scss but command ng config defaults.styleExt=scss gives me Value cannot be found.

How to change default style extention?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (2 by maintainers)

Most upvoted comments

When I run that command ng config schematics.@schematics/angular:component.styleext scss I get error

Invalid JSON character: "s" at 0:0.
Error: Invalid JSON character: "s" at 0:0.
    at _readValue (C:\strony\www\infirma\admin\node_modules\@angular-devkit\core\src\json\parser.js:567:19)
    at parseJsonAst (C:\strony\www\infirma\admin\node_modules\@angular-devkit\core\src\json\parser.js:605:17)
    at Object.parseJson (C:\strony\www\infirma\admin\node_modules\@angular-devkit\core\src\json\parser.js:631:12)
    at normalizeValue (C:\strony\www\infirma\admin\node_modules\@angular\cli\commands\config.js:128:19)
    at ConfigCommand.set (C:\strony\www\infirma\admin\node_modules\@angular\cli\commands\config.js:195:23)
    at ConfigCommand.run (C:\strony\www\infirma\admin\node_modules\@angular\cli\commands\config.js:168:18)
    at C:\strony\www\infirma\admin\node_modules\@angular\cli\models\command-runner.js:278:30
    at Generator.next (<anonymous>)
    at fulfilled (C:\strony\www\infirma\admin\node_modules\@angular\cli\models\command-runner.js:4:58)
    at <anonymous>

Edit:

I’ve created new project and I know that I have to add to angular.json in every project

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

I found the command, in the stackoverflow site: ng config schematics.@schematics/angular:component.styleext scss. This command will automatically add the “schematics” section halfer mentioned to the angular.json file e generate the next components with scss instead of css

Heya, you can see here how to change the default for component generation: https://github.com/angular/angular-cli/wiki/stories-css-preprocessors

You have to add in in every project:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
...
  "projects": {
    "frontend": {
      ...
      "schematics": {
        "@schematics/angular:component": {
          "styleext": "scss",
        }
      }
}