-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Component-level css not loading into stories #12144
Comments
Experiencing the same issues. I added some style imports to a
But any |
@dyaeger did it work when you added the styles file imports to preview.js? |
@akhiltheguitarist - It did but with over 50 different components it is just too much to be importing by hand. Perhaps fine if it's a new project and users are weary of needing to do this for each component with its own |
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 have been encountering the same issue, only when building storybook and deploying it. Launching storybook in dev mode, it seems to load the styles correctly.
|
Could we somehow get an update regarding this issue? |
@ruijdacd Yes, nobody has responded yet. |
Try upgrading to 6.1?
Also did you try adding |
We changed the way we map static directories in 6.0. It was modified slightly in 6.1.6: #13245 @jonniebigodes can you track this down? |
I've setup a repo here to test this issue. So far i was unable to replicate the issue. The repo contains three branches:
Testing done:
Based on testing done the css was loaded correctly into the component in Storybook. If anyone is willing to share a more complex based on the comment here i'm willing to adjust accordingly and test it further. Because the only possible issue here is that there could be a clash between Storybook's own css and some external /local css implementation. Feel free to let me know and we'll take it from there. Stay safe all. |
@jonniebigodes we're using scss and tailwind here... I can confirm that no scss imported in component level are considered... styles are completely ignored. And I can't even understand how can storybook load a jsx file and ignore scss that is imported within... but it is exactly what's happening. |
@Hamdan85 if you could push a small repo and share it we'd appreciate it and help us get to the bottom of this. Sounds good? |
unfortunatelly no because it's my company's code...
But man, nothing much... using a react component that imports a scss file
already causes it.
Em seg., 1 de fev. de 2021 às 22:05, jonniebigodes <notifications@github.com>
escreveu:
… @Hamdan85 <https://github.com/Hamdan85> if you could push a small repo
and share it we'd appreciate it and help us get to the bottom of this.
Sounds good?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#12144 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAOMOSSKBKVU2MD2LXZQGEDS45FWBANCNFSM4QFJ6Y6Q>
.
|
@jonniebigodes for your setup repo, can you try importing a scss file in preview.js instead? Because that is the issue I'm having currently. When in development mode, it runs fine - but is somehow missing when built |
I can confirm css files work, using sass to preprocess the scss files before build/dev into css files. But I feel like this is more of a hack than a real solution... |
Hi there, I've landed on this thread after experiencing the same issue. That is, everything is fine for me in development, but when I build my Storybook instance, the The project is open-source and is here. It is a very simple exported component. I build my Storybook instance to the I recently updated the Storybook instance to > 6, and that's when the "css missing in production" issue started happening. "@storybook/addon-a11y": "^6.1.20",
"@storybook/addon-actions": "^6.1.20",
"@storybook/addon-essentials": "^6.1.20",
"@storybook/addon-links": "^6.1.20",
"@storybook/react": "^6.1.20",
To alleviate the issue for now, I've imported an already built version of my Here are a few of the things I've tried:
I wanted to document this here because while I'm sure it's a small thing, it's kinda an important issue that needs to be sorting out. Hopefully the information provided can help track it down. Thank you. |
I can also confirm this behavior on a Vue-based project. Tried different things but it seems that any kind of scss is ignored when building the docs. This works:
This doesn't work:
Doesn't work either:
|
Same issue, global level scss loads and compiles or any scenarios described by @andreitere I tested the front end of my application and vue is loading the style just fine in the component. This is a really nasty bug. Trying to down grade to 6.0.0..... |
This is happening with vue with vuetify, any update to version 6, Some more info, if i import each of the files, from vuetify, it works. |
I had the same issue where styles using SCSS in Vue Single File Components where ignored when building the Storybook using <style lang="scss">
// ...
</style> When the style was marked as Note that my Vue components are in a Yarn workspace and they are split in several packages that are marked as ES Modules using I managed to fix this by adding a new rule for // .storybook/main.js
module.exports = {
// ... other non-important stuff
webpackFinal: (config) => {
config.module.rules.push({
test: /\.scss$/,
sideEffects: true,
use: ['vue-style-loader', 'css-loader', 'sass-loader'],
});
return config;
},
}; |
I am now trying this in Svelte, same issue. |
@Sumolari Thank You Sir! It worked for me in SFC with vue3 |
If smb still has problem of using css-modules in storybook with this solved the issue for me - https://github.com/Negan1911/storybook-css-modules-preset |
^ Great addon. Works perfectly |
For me, putting
Webpack
Versions
|
I solved it using the sass-loader, css-loader and style-loader in main.js:
|
Incase someone is still facing the issue in 2022. So I had similar issue that everything was working fine just component css module styles were not being picked. I installed these 2 packages Then in your .storybook folder main.js file inside the addons array ad them like this `
` |
Installing Also, for anyone looking for the solution, make sure you install |
I still have this issue using vue 3 with vite and storybook 7. |
Surprisingly, despite all the efforts (if any) of the developers, I encountered this 2019 bug in the middle of 2023. Both version 6 and 7 work equally badly on vite! Any import from Stylus causes error. SCSS styles imported as CSS, but imported classNames totally ignored. Do we need to use vanilla HTML/CSS in 2023 to use Storybook? |
same issue here. :/ |
Same now, nothing above helped (Vue 2 + Storybook 6/7) |
Greetings from March 2024! Is there no solution yet to this issue? (Storybook 7.6.10 + React 18) |
We're just migrating everything to tailwind, hours and hours of messing with it and it never worked 😵💫 |
Any updates on this issue? |
I created a react app using create-react-app, and added a button component, a css for the button. When I load the story for the button, the styles are not loaded for the button. Pasting below, the related files. Is there any configuration that I am to do, to get this up and running with styles?
github repo for the project
Component: index.js
style.css:
Story file:
System info:
The text was updated successfully, but these errors were encountered: