Closed martinsik closed 2 years ago
Hi there @martinsik ! Thanks for filing an issue! :)
I see the confusion! The styles
option you mention is available for the @nrwl/storybook:build
executor. However, in the case of Angular projects, you are using the @storybook/angular:build-storybook
. I see that your project has a build
target, so you can add the styles in the build
target instead of the build-storybook
target, and I expect it should work. If you also read the documentation for adding styles maybe it can help in your case. You can also read the official Storybook docs for adding styles to Angular Storybook projects. Keep in mind that in the case of Angular projects, Nx is just using the native Storybook builders, so any issues that come up are best addressed with that in mind.
Let me know if my suggestions help!
Hi @martinsik ! Did you get a chance to look into this?
@mandarini Hi, thanks for your reply!
My goal was to be able to compile styles without compiling the Angular application (that's why I have a separate target build-storybook
).
Right now as a workaround I have dependsOn
option that first compiles the app and then I'm using staticDirs
in my Storybook config to map the compiled dist
assets to the Storybook app. This works but every startup is slow.
I'm looking into https://storybook.js.org/docs/angular/configure/styling-and-css now and they don't mention that styles
option supports also objects as https://angular.io/guide/workspace-config#styles-and-scripts-configuration does. So maybe this is a problem with Storybook after all.
Ahh I see! Yeah, that sounds like it must be on the Storybook side. Do you mind creating a new issue on the Storybook repository? And mention this one. Let's close this for now, and if it turns out it's on Nx, we can reopen!
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
When I have the following project configuration for an Angular Storybook target,
storybook.scss
will be correctly compiled and saved todist/storybook/myapp/main.css
. However, none of the other style objects withbundleName
are saved anywhere. They are processed (when I misspell any name or use wrong import it throws an error) but not saved todist/storybook/myapp
directory. When I use the same"styles"
config in an Angular project the styles are properly generated and saved.The
styles
option should be supported according to https://nx.dev/packages/storybook/executors/build#styles.Expected Behavior
All styles defined using a config object should be saved to
dist/storybook/myapp
directory like it does with normal Angular projects.I tested this problem with Nx@13 and Nx@14 and the behavior is the same.
Steps to Reproduce
npm ci
npm run sb:build
dist/storybook/myapp
dir. It's missing all bundled styles (it should containblue.theme.css
,green.theme.css
andpurple.theme.css
).When you build the Angular project with
npm run build
it generates bundled styles intodist/apps/myapp
as expected.Environment