get / set已被弃用,转而使用config命令

时间:2018-05-07 22:09:30

标签: angular angular-cli

在命令行使用angular-cli,我执行了:

ng set defaults.styleExt styl

将默认样式设置为Stylus,我得到了这个回复:

  

get / set已弃用,取而代之的是config命令

我想更改EXISTING项目的样式扩展名以使用SCSS。如何使用config命令执行此操作? ng config的文档在哪里?

我使用的是Angular CLI v6.0.0

ng帮助说:

  

config获取/设置配置值

但没有详细说明。感谢

3 个答案:

答案 0 :(得分:22)

好的,我对使用以下项目生成的项目进行了区分:

projects.PROJECT_NAME.schematics

和没有--style标志的情况相同,angular.json配置文件中的差异在附加的2个.png文件中表示。

使用这些差异,我手动对 angular.json 进行了如下更改:

(1)按如下方式更改"schematics": { "@schematics/angular:component": { "styleext": "styl" } }

projects.PROJECT_NAME.architect.build.options.styles

(2)按如下方式更改"styles": [ "src/styles.styl" ]

projects.PROJECT_NAME.architect.test.options.styles

(3)按如下方式更改"styles": [ "styles.styl" ]

.css

(4)将src / styles.css重命名为src / styles.styl

您现有的组件将很乐意继续使用.styl,但现在将使用 m<- structure(list(sound = structure(c(2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L), .Label = c("Silence", "English"), class = "factor"), `Reading condition` = structure(c(1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L), .Label = c("normal", "trailing mask" ), class = "factor"), diff = structure(c(2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L), .Label = c("Easy questions", "Difficult questions" ), class = "factor"), Mean = c(0.283, 0.36, 0.183, 0.227, 0.19, 0.347, 0.197, 0.333), SD = c(0.500558971667007, 0.34814947033031, 0.497195715406262, 0.447163568809774, 0.49804988833968, 0.361515576848703, 0.498812908487118, 0.373926502247132), SE = c(0.100111794333401, 0.0696298940660619, 0.0994391430812524, 0.0894327137619548, 0.099609977667936, 0.0723031153697406, 0.0997625816974236, 0.0747853004494263)), .Names = c("sound", "Reading condition", "diff", "Mean", "SD", "SE"), row.names = c(NA, 8L), idvars = c("sound", "mask", "diff"), rdimnames = list(structure(list( sound = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c("English", "Silence"), class = "factor"), mask = structure(c(1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L), .Label = c("No", "Yes"), class = "factor"), diff = c("difficult", "easy", "difficult", "easy", "difficult", "easy", "difficult", "easy")), .Names = c("sound", "mask", "diff"), row.names = c("English_No_difficult", "English_No_easy", "English_Yes_difficult", "English_Yes_easy", "Silence_No_difficult", "Silence_No_easy", "Silence_Yes_difficult", "Silence_Yes_easy" ), class = "data.frame"), structure(list(variable = structure(c(1L, 1L), .Label = "accuracy", class = "factor"), result_variable = structure(1:2, .Label = c("M", "SD"), class = "factor")), .Names = c("variable", "result_variable" ), row.names = c("accuracy_M", "accuracy_SD"), class = "data.frame")), class = "data.frame") 个文件生成新组件。

PNG格式的差异如下:

enter image description here

...

enter image description here

答案 1 :(得分:19)

对于Angular 6,您想使用以下命令:

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

这将自动将提到的“示意图”部分上半部分添加到angular.json文件中。

这是官方文档: https://github.com/angular/angular-cli/wiki/stories-css-preprocessors

答案 2 :(得分:7)

ng config projects.PROJECT_NAME.schematics.@schematics/angular:component '{ styleext: "scss"}'

用于特定项目或所有项目的默认项目

ng config schematics.@schematics/angular:component '{ styleext: "scss"}'