Tailwind(Nativewind) css is not working with React + Vite in React-Native-Web #28399
-
SummaryHello! We are working with Storybook 8 with React + Vite. We are using Tailwind CSS with Nativewind. We have configured everything mentioned in the Tailwind, Nativewind, and Storybook migration/setup guide. But TailwindCSS classes won't show up Additional information
Please suggest, what we are missing here! Create a reproductionNo response |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
TLDR// vite.config.ts
{
plugins: [
react({
babel: {
// https://www.nativewind.dev/guides/babel-transform-only
plugins: [['nativewind/babel', { mode: 'transformOnly' }]],
},
}),
],
resolve: {
alias: {
'react-native': 'react-native-web',
},
},
}; How it worksI don't use Storybook, but I got it working by applying the
The So, all that is really needed is to ensure that the nativewind plugin is used by react babel setup and ensure that vite resolves |
Beta Was this translation helpful? Give feedback.
-
Try this code.
|
Beta Was this translation helpful? Give feedback.
-
heres an example project that i setup https://github.com/dannyhw/vite-rnw-example currently working on better vite support for react native storybook but needs some time |
Beta Was this translation helpful? Give feedback.
there is now storybook/react-native-web-vite