作者:手机用户2502870863 | 来源:互联网 | 2022-12-26 13:29
我包括一个独立的构建模块,它将.scss(SASS)用于使用纯CSS设置的现有Angular应用程序.是否可以将它们彼此相邻并且是否需要任何自定义配置,例如在angular-cli.json
默认部分中:
"defaults": {
"styleExt": "css? scss?"
}
或者只能使用两者中的一个?
1> Bernoulli IT..:
编辑Angular 6+
在Angular的GitHub页面上找到:
仍支持stylePreprocessorOptions。您将不得不手动更新新生成的angular.json
。它的新位置在json的“ options”块内。
配置示例如下所示:
"options": {
"outputPath": "../webapp",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
{
"glob": "**/*",
"input": "src/resources",
"output": "/resources"
},
],
"styles": [
"src/styles.scss"
],
"stylePreprocessorOptions": {
"includePaths": [
"src/styles"
]
},
"scripts": []
}
注意更改的路径。
原始答案
实际上,通过将"styleExt"
设置为,它开箱即可使用"css"
。特定模块中的许多组件都在使用SASS。我有一个包含变量和mixins的sass文件夹,angular-cli.json
需要此设置才能正确编译/处理这些scss文件:
"stylePreprocessorOptions": {
"includePaths": [
"sass"
]
}
该应用程序可以完美地结合使用css和scss文件。我假设通过命令添加组件时,此styleExt
参数仅用于默认组件样式(css, scss, less
)文件生成angular-cli
。