Styled Components not working in a Storybook static build?
See original GitHub issueDescribe the bug We have a Storybook 5.3.3 running perfectly fine in dev mode, components utilizing React 16.8.6, Styled Components 4.4 (also tried the new 5.0) and Typescript 3.7 (with ts-loader 6.2.1).
When built for static deployment, things work fine except no styles get injected into the head, so all components are unstyled. Class names are generated fine, and no errors are thrown. Somehow, it appears that SC fails to work within Storybook’s iframe?
To run the build, tried deploying to Surge as well as npx http-server .out
per docs, same result 😦
To Reproduce Yet to repro using a bare-bones project setup… Just curious if it’s a known issue?
Expected behavior
Styles should be present inside iframe head’s style
tag
Screenshots
System:
System
OS: macOS 10.15.2
CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
Binaries:
Node: 8.16.1 - ~/.nvm/versions/node/v8.16.1/bin/node
Yarn: 1.21.1 - ~/Projects/philo-fe/node_modules/.bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v8.16.1/bin/npm
Browsers:
Chrome: 79.0.3945.117
Firefox: 69.0.3
Safari: 13.0.4
npmPackages:
@storybook/addon-a11y: ^5.3.3 => 5.3.3
@storybook/addon-actions: ^5.3.3 => 5.3.3
@storybook/addon-knobs: ^5.3.3 => 5.3.3
@storybook/addon-viewport: ^5.3.3 => 5.3.3
@storybook/react: ^5.3.3 => 5.3.3
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Error in storybook when using styled-component styling ...
An error occurs if a styling component is included in the styled component in the storybook. import { Flex } from "rebass" export...
Read more >Adventures with Storybook, TypeScript, and Styled Components
A collection of known issues and workarounds for Storybook with CSF stories, MDX docs, TypeScript, and Styled Components.
Read more >Setup Storybook - JS.ORG
Render component styles. Storybook isn't opinionated about how you generate or load CSS. It renders whatever DOM elements you provide. But sometimes, things...
Read more >Tooling - styled-components
If you do not use this plugin and try to server-side render ... plugin while allowing the unejected tooling to handle the Babel...
Read more >Setting up Storybook with Typescript and Styled Components
... but got storybook working with Typescript and Styled Components.Code: https://github.com/benawad/codeponder/ issues /2Watch at 6pm CT: ht.
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 FreeTop 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
Top GitHub Comments
Hi everyone! Seems like there hasn’t been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don’t have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
I was able to work around this by disabling “speedy” mode in styled-components by adding the following to my
webpack.config.js
for Storybook: