Tailwind(Nativewind) css is not working with React + Vite in React-Native-Web #28399
Replies: 3 comments
-
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.
-
Summary
Hello!
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
main.ts
preview.ts
global.css
postcss.config.js
tailwind.config.mts
vite.config.mts
dependencies versions
TextComponent.tsx
Please suggest, what we are missing here!
Create a reproduction
No response
Beta Was this translation helpful? Give feedback.
All reactions