要将Sass的根目录设置为Angular项目中的特定目录,需要进行以下步骤:
angular.json
文件。angular.json
文件,并找到architect -> build -> options -> styles
部分。styles
数组中,找到你想要设置为Sass根目录的样式文件路径。下面是一个示例:
"architect": {
"build": {
"options": {
"styles": [
"src/styles.scss",
"src/app/my-component/my-component.scss"
]
}
}
}
假设你想要将src/app/my-component/my-component.scss
设置为Sass根目录,你可以将代码修改为:
"architect": {
"build": {
"options": {
"styles": [
"src/styles.scss",
{
"input": "src/app/my-component/my-component.scss",
"inject": false
}
]
}
}
}
在上面的示例中,我们将src/app/my-component/my-component.scss
添加到styles
数组中,并将其包装在一个对象中。通过设置inject
为false
,我们告诉Angular不要将此样式文件注入到全局样式中。
通过以上步骤,你就可以将Sass的根目录设置为Angular项目中的特定目录了。