如何开动装载机的角度?
我尝试使用@import "theme.scss"; inside*.scss`文件。
但我得到了信息;
导入未找到或不可读的
文件: theme.scss。
我不使用webpack,只使用tsconfig和angular.jon
其中文件theme.scss包含变量:
$border-radius: 10px;
$main: rgb(20, 100, 192);发布于 2020-01-13 11:46:00
将.scss文件导入其他.scss文件
可以使用资产路径中文件的相对路径来指定其他.scss文件中的.scss。
默认的资产路径应该是
"assets": [
"src/favicon.ico",
"src/assets"
]它在angular.json文件中定义。
示例:
有一个app.component.scss
theme.scss文件的./src/assets/theme/theme.scss中
然后在app.component.scss中导入它,比如:
@import '../assets/theme/theme.scss';指定样式预处理器选项以缩短导入
如果您想像您所描述的那样缩短路径,只需将路径添加到stylePreprocessorOptions文件中:
"architect": {
"build": {
...
"options": {
...
"stylePreprocessorOptions": {
"includePaths": [
"./src/assets/style/theme"
]
},
},
"test": {
...
"options": {
...
"stylePreprocessorOptions": {
"includePaths": [
"./src/assets/style/theme"
]
}
}
}
}那么您应该能够像@import 'theme.scss';一样包含您的文件
欲了解更多信息,请阅读:https://github.com/angular/angular-cli/wiki/stories-global-styles
描述更改后的更新
我想你设置了错误的相对路径。因此,您需要这样设置stylePreprocessorOptions:
"includePaths": ["./src/lib"]在build和test中
设置之后,您可以将任何主题文件放入其中,例如:
./src/lib/theme.scss并像@import 'theme.scss';一样导入它
https://stackoverflow.com/questions/59715916
复制相似问题