在Angular 6+(styleExt)中使用scss作为默认样式表 [英] Using scss as default style sheet in Angular 6+ (styleExt)
问题描述
显然,从Angular 6开始,声明默认样式表扩展名的方式已更改. angular.json
中的styleExt
属性不再被识别.
Apparently the way to declare the default stylesheet extension changed from Angular 6 onwards. The styleExt
property in the angular.json
is not recognised any longer.
对于新项目,可以在new
命令的CLI --style=scss
上使用选项进行设置.
For new projects this can be set with an option on the CLI --style=scss
on the new
command.
但是,如果存在我从Angular< 5迁移的项目,或者在项目创建过程中忘记这样做,您将如何更改呢?
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?
这个问题与Angular的5到6版本的重大更改密切相关.
This question is meant to be strictly related to the breaking changes by the version 5 to 6 of Angular.
推荐答案
此设置的位置在angular.json
中已更改.现在有2种方法可以设置此选项.
The position on which this is set changed in the angular.json
. There are 2 ways to set this option now.
通过Angular CLI:
Via the Angular CLI:
ng config schematics.@schematics/angular:component.styleext scss
直接在angular.json
中:
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
}
这篇关于在Angular 6+(styleExt)中使用scss作为默认样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!