-
I am having issues with my React component library. I am trying to bundle it to an npm package, it seems to be working, but I haven't been able to bundle Tailwind with the library package.
Any idea what is the problem ? Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
The final CSS bundle that tailwind generates classes in is imported in your storybook. You need to also copy that file specifically into your dist, export it in package.json, and then import it inside your consumer app. Edited the package.json inside This is assuming your consumers may not run tailwind, so the entire CSS is necessary. You may also provide your tailwind config as a preset if you want tailwind consumers to use it (that way they can get the specific styles of the components they use instead of every bundled style) |
Beta Was this translation helpful? Give feedback.
Stackblitz doesn't save updates in node_modules, here's the relevant piece that I added
The (sort of) drawback with using tailwind for component libs is that tailwind just generates one single CSS file, so even if consumer uses 1 component, you have to import that entire CSS file in the consuming app (
style.css
in your dist)I am not sure if there's a way to auto inject styles if a component is used, but you can…