我正在尝试使用stylePreprocessorOptions
以便包含我的变量文件夹的路径对于库项目像这样:
"stylePreprocessorOptions": {
"includePaths": [
"styles/variables"
]
}
然后我在scss文件中使用@import 'colors';
。但是在执行ng serve
时它不起作用:
@import 'colors';
^
Can't find stylesheet to import.
这里是angular.json中的完整库:
"ui-table": {
"root": "libs/ui/table",
"sourceRoot": "libs/ui/table/src",
"projectType": "library",
"prefix": "xxx",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "libs/ui/table/tsconfig.lib.json",
"project": "libs/ui/table/ng-package.json",
"stylePreprocessorOptions": {
"includePaths": [
"styles/variables"
]
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["libs/ui/table/tsconfig.lib.json"],
"exclude": ["**/node_modules/**"]
}
}
},
"schematics": {
"@nrwl/schematics:component": {
"styleext": "scss"
}
}
},
如何在Angular的库中使用stylePreprocessorOptions
?
谢谢!
不在angular.json中。
在ng-package.json的styleIncludePaths
中包含路径:
"lib": {
"entryFile": "src/public-api.ts",
...
"styleIncludePaths": [ <---------
"src/lib/scss" <-------------
]
...
}