No global style in Storybook with Angular 12
See original GitHub issueCurrent Behavior
The global style is not applied in Storybook.
It has been added in preview.js
as follows:
import '!style-loader!css-loader!sass-loader!../../../apps/client/src/styles.scss';
Expected Behavior
The global style gets applied to each Storybook story.
Steps to Reproduce
- Clone https://github.com/ghostfolio/ghostfolio
- Install dependencies:
yarn install
- Start Storybook:
yarn start:storybook
- Open http://localhost:4400/?path=/story/value--currency
- E.g.
d-flex
(utility class from Bootstrap) is not applied
Environment
Node : 16.6.2
OS : darwin x64
yarn : 1.22.5
nx : 12.9.0
@nrwl/angular : 12.8.0
@nrwl/cli : 12.8.0
@nrwl/cypress : 12.8.0
@nrwl/devkit : 12.8.0
@nrwl/eslint-plugin-nx : 12.8.0
@nrwl/jest : 12.8.0
@nrwl/linter : 12.8.0
@nrwl/nest : 12.8.0
@nrwl/node : 12.8.0
@nrwl/tao : 12.8.0
@nrwl/workspace : 12.8.0
@nrwl/storybook : 12.9.0
typescript : 4.3.5
Issue Analytics
- State:
- Created 2 years ago
- Reactions:9
- Comments:21 (6 by maintainers)
Top Results From Across the Web
Global SCSS style is no longer loaded in Storybook with ...
To do so, I upgraded Angular and Material to version 12 with the Angular Update Guide, Storybook to version 6.3 with npx sb...
Read more >6 Ways To Configure Global Styles for Storybook | by Jennifer Fu
It is a common task to configure global styles for Storybook, such as background color, color, font family, and font sizes. In this...
Read more >Reopened bug. Angular 13. Global styles no longer work in ...
Global styles no longer work in SB 6.4 (CSS or SCSS) #16950 ... a NX issue or Storybook issue, but I am sure...
Read more >Storybook Addon Next
Next.js Routing. Overriding defaults; Global Defaults; Default Router; Actions Integration Caveats. Sass/Scss; Css/Sass/Scss Modules; Styled JSX; Postcss ...
Read more >Import Your Angular Scss Files in Storybook | Bits && Pixels
How to deal with styles from global/external *.scss files when ... when Angular 13 came out and I could not get gobal styles...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That didn’t work entirely but did point me in the right direction to configure styles in two places:
nx storybook ...
usesprojects.[project].architect.storybook.options.styles
nx e2e ...
usesprojects.[project].architect.build-storybook.options.styles
(it’s a pity that an import in preview.js never worked; angular.json is the wrong place for this imho)
Hey you all! I spend an eternity trying to fix this issue.
In my case, the problem was that the targets (
storybook
andbuild-storybook
) were generated (by nx) with wrong configuration.I generated it via the
nx g @nrwl/angular:storybook-configuration my-lib
command, and the generated targets looked like this. Notice the projectBuildConfig:I had to manually update the
projectBuildConfig
option to look like this -"projectBuildConfig": "my-lib:build-storybook"
.Now my complete configuration looks like this:
Everything works as expected now.
Using
@nrwl/storybook : 13.8.2
.Update: For more context, not sure if it’s relevant or not, but the library I was adding storybook configuration into, is buildable - it already had the
build
target (with the@nrwl/angular:ng-packagr-lite
executor) when I was generating the storybook configuration.