I am trying to create a standalone UI library using React and Tailwind. I am using Storybook to test the components. Specifically, there is no builder like Vite or Next.js involved.
Following the instructions in the docs, I was able to setup PostCSS to generate the final CSS. The only issue is that Storybook does not refresh when I make code changes (especially tailwind.config.js). I have postcss running with --watch, but I suspect it doesn't look for changes to tailwind.config.js. What's the best way to improve the developer experience? Ideally, I would like PostCSS to be triggered whenever tailwind.config.js changes or any of the React components change.
Here's my minimal repo: https://github.com/nareshbhatia/tailwindcss-storybook
Here are the relevant scripts in package.json. Running npm run dev starts up storybook, the bundler and postcss in watch mode:
{
"scripts": {
"dev": "run-p bundle generate-css storybook",
"bundle": "tsup src/index.ts --format esm,cjs --dts --external react --watch",
"generate-css": "postcss src/styles/tailwind.css -o public/main.css --watch",
"storybook": "start-storybook -p 6006"
}
}