Issue
I'm trying to use stylePreprocessorOptions in order to include a path to my variables folders for a library project like so :
"stylePreprocessorOptions": {
"includePaths": [
"styles/variables"
]
}
Then I use @import 'colors'; within the scss file. But it doesnt work while doing ng serve :
@import 'colors';
^
Can't find stylesheet to import.
Here is the full library in 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"
}
}
},
How can I use stylePreprocessorOptions in a library in Angular?
Thanks!
Solution
Not in angular.json.
Include the path to your scss folder with styleIncludePaths in the librairies' ng-package.json
"lib": {
"entryFile": "src/public-api.ts",
...
"styleIncludePaths": [
"relative/path/to/scss/folder"
]
...
}
finally import the files from the referenced scss folder without prefix path as follows
@import "filename";
Answered By - Zainu
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.