storybook: Angular 13. Global styles no longer work in SB 6.4 (CSS or SCSS)
Describe the bug
- Clean NG 13 project + SB 6.4.0
- Added global plain old CSS style as described in https://storybook.js.org/docs/angular/configure/styling-and-css#importing-css-files
- Result. No global styles applied.
To Reproduce
Attaching a minimal reproduction generated myself as npx sb@next repro fails. styles_issue_repro.zip
Just run the below to see the reproduction of the issue
npm i && npm run storybook
Expected result
Global styles should apply, i.e.
- All divs must have a red background
- A top div in http://localhost:6006/?path=/story/example-introduction--page must have a blue background
System
macOS Monterey OS Version 12.0.1 npm 6.14.15 node v14.18.1
Additional context n/a
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 26
- Comments: 18 (6 by maintainers)
Thanks for your patience everybody! Closing this.
It is not resolved though! External static styles are not loaded as mentioned in my last comment so the original issue is still happening
Any news when this will be fixed ? I tried the workaround and it doesn’t seem to work.
Found a work-around.
ng run test:storybook
h/t @ThibaudAV for pointers in his repos
Should probably be fixed in the upcoming releases of SB
Thank you. Issues resolved:
Issues still to be resolved:
Probably a bit of cross contamination here, but does anyone have a workaround for using this in an nx monorepo?
EDIT: This looks like a suitable solution https://github.com/nrwl/nx/issues/8681
yes exactly.
but you don’t have to add
"styles": ["src/styles.scss"]
if you want to add the same as thebrowserTarget
Thestyles
options in storybook builder is to override allstyles
formbrowserTarget
There are still 2 points to do to improve storybook on this subject.
but the idea was to have this workaround quickly to avoid loss of functionality. I also hope it will make easier the maintenance during angular version upgrades 🤞
You have to add them in angular.json. Refer to angular docs not an SB “issue”
@shilman Could you label this issue as “has workaround”? it will help others to stop digging 😃
preview.js
runs in the browser, soprocess.exit
isn’t meaningful there