Using SCSS/Sass as default style sheet in Angular 6+ (styleExt)

匿名 (未验证) 提交于 2019-12-03 08:48:34

问题:

Apparently the way to declare the default stylesheet extension changed from Angular 6 onwards. The styleExt property in the angular-cli.json is not recognised any longer.

For new projects this can be set with an option on the CLI --style=sass on the new command.

However, how do you change this for exsting projects that I migrate from Angular <5 or if you forgot to do this during project creation?

This question is meant to be strictly related to the breaking changes by the version 5 to 6 of Angular.

回答1:

The position on which this is set changed in the angular.json. There are 2 ways to set this option now.

Via the Angular CLI:

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

Directly in the angular.json:

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


回答2:

For exsting projects, try the command bellow

ng set defaults.styleExt scss 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!