I am working on an angular library (version 9.1.11) with storybook, where I want to add styles globally. I know that for ng-packagr versions 9.x and above it is possible to copy assets into your library package as part of the build process to add styles globally.
"ng-packagr:" "~9.1.5" was already in devDependencies in my package.json, so I didn't reinstall it.
What I did is the following:
I created the global.scss file in the root of my library.
I added "assets" to my ng-package.json targeting my global.scss file.
I added styles to my global.scss file.
I ran an npm run build to copy the global.scss file into my dist folder.
After that the styles from my global.scss file are not being applied to my library.
What am I missing and why are the styles not being applied globally?
And how can I add styles globally to my library correctly using ng-packagr?
This is what the files in my library look like:
Here's what my ng-package.json looks like:
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/libs/angular-components",
"assets": ["./global.scss"], <- ADDED HERE
"lib": {
"entryFile": "src/public_api.ts",
"umdModuleIds": {
"color": "color",
"uuid": "uuid"
}
},
"whitelistedNonPeerDependencies": [
"color",
"tslib",
"uuid"
]
}
