question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tailwind 3 doesn't work with storybook/webpack setup

See original GitHub issue

I’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:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:24 (1 by maintainers)

github_iconTop GitHub Comments

19reactions
ManiruzzamanAkashcommented, Jan 21, 2022

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 -

import '!style-loader!css-loader!postcss-loader!tailwindcss/tailwind.css';

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

17reactions
sachinmourcommented, Dec 12, 2021

@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-issue

If you guys don’t agree, let me know, otherwise, I’ll close this issue in 2 days.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found