Replies: 2 comments 4 replies
-
@fnumatic Hey! Do you mind attaching a repro and sharing which Node version you're using? |
Beta Was this translation helpful? Give feedback.
3 replies
-
hej, i had the same problem today. i got it working: instead of doing an (await import('@tailwindcss/vite')).default() storybook comes back to life ;) according to: but deprecation still stays the same for cjs ;) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Environment
Project: Electron application
Dependencies:
Storybook (@storybook/react-vite): [8.5.8]
Vite: [6.1.1]
Tailwind CSS: [4.0.7]
@tailwindcss/vite: [4.0.7]
Problem
I’m working on an Electron app where I use Storybook to test and develop React components styled with Tailwind CSS. Initially, I encountered an issue where Tailwind CSS classes were not being applied to my Storybook stories, even though the CSS file (containing Tailwind directives like @tailwind base;) was loading correctly. This resulted in unstyled components in the Storybook UI, making it unusable for testing my styled components.
The root cause seems to be that Storybook uses its own Vite instance, which doesn’t include the Tailwind CSS plugin by default. As a result, the Tailwind directives were not being processed, and the utility classes were not generated.
Solution
To resolve this, I modified my .storybook/main.ts file to integrate the @tailwindcss/vite plugin into Storybook’s Vite configuration using the viteFinal hook. Here’s the working configuration:
This change successfully processes Tailwind CSS directives, and the utility classes are now applied correctly in my Storybook stories.
Warning Encountered
While this solution works, I receive the following warning in the terminal when running Storybook:
This warning appears to stem from the use of CommonJS-style dynamic imports (import()) for @tailwindcss/vite in the viteFinal function. According to the Vite documentation, the CommonJS build of Vite’s Node API is deprecated, and this could pose compatibility issues in future releases.
Additional Notes
When attempting to integrate the Tailwind CSS plugin (@tailwindcss/vite) into a Storybook setup using a normal import in the .storybook/main.ts file, you may encounter the following error:
Beta Was this translation helpful? Give feedback.
All reactions