I attempted to incorporate global styles in my Angular app similar to how it's done, but unfortunately, it didn't work as expected.
The library I'm using is named example-lib. To include the styles, I added styles.css
in the directory /projects/example-lib/
. In the main angular.json
file, I included the styles like this:
...
"example-lib": {
"root": "projects/example-lib",
"sourceRoot": "projects/example-lib/src",
"projectType": "library",
"prefix": "ngx",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/example-lib/tsconfig.lib.json",
"project": "projects/example-lib/ng-package.json",
"styles": [
"projects/example-lib/styles.css" <!-- HERE
],
},
...
When attempting to build the library with the command:
ng build example-lib
An error occurred:
Schema validation failed with the following errors:
Data path "" should NOT have additional properties(styles)
I believe there might be another method for adding global styles to a separate library. Can anyone provide guidance on this?