tailwind 3 doesn't work with storybook/webpack setup
See original GitHub issueI’m using macOS, Chrome v96, Node.js 16
I created a github repository with this exact issue - https://github.com/sachinmour/tailwind-issue
Basically just do yarn
and yarn storybook
and you’ll see storybook loaded correctly.
change package.json to use tailwind ^3.0.0
and
run yarn
and yarn storybook
again and
you’ll see no tailwind is loaded inside storybook.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:24 (1 by maintainers)
Top Results From Across the Web
Tailwind css classes not showing in Storybook build
I think the key difference in our configurations is that I am not making changes to Storybook's webpack config in main.js.
Read more >How to set up Storybook with Next.js and Tailwind CSS
Introduction · Version · Initializing Storybook · Installing PostCSS Add-ons · Adding Webpack as a resolution dependency · Replace .storybook/main.js.
Read more >a component library with Storybook, Tailwind, and Typescript.
If you face problems importing the tailwind file, you need to add a sass-loader to your webpack configuration on main.js . If you...
Read more >Webpack - Storybook
js file. The value should be an async function that receives a Webpack config and eventually returns a Webpack config. Default configuration. By ......
Read more >Styles not applying with TailwindCSS's @apply on vue 3 #13962
My settings work if you use the TailwindCSS classes, not with @apply (PostCSS). To Reproduce Use the settings listed below. Expected behavior Tailwind...
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
Hi, the above staffs didn’t worked for me. here is the quick solution - in
.storybook/preview.js
file add this line to compile tailwind generated css files like this -Here
tailwindcss/tailwind.css
is the tailwind css file. Look, important is I’ve to add!postcss-loader!
to compile tailwind generated css.There are more solutions answered here - https://stackoverflow.com/a/70805809/5543577
@nvsd @LinnJS @paulgendek so, I figured out what the problem was, I don’t think it was because of what you guys said. The problem is in v3 of tailwindcss has JIT enabled by default and that means it’ll only add css that you use in your components, and in v2 if you didn’t define
mode
and left the purge config as an empty array, it would add all of tailwindcss, but now you MUST define content property with all the places you’re using tailwindcss and as soon as I updated content to include my src folder, everything started working as usual. I’ve updated my original repo with working code https://github.com/sachinmour/tailwind-issueIf you guys don’t agree, let me know, otherwise, I’ll close this issue in 2 days.