React Native Web support for Vite
npm install vite-plugin-react-native-web
Add React Native Web support to Vite by removing Flow types, aliasing react-native to react-native-web and transforming .js files as .jsx files using ESBuild.
Just install it:
``bash`
npm i vite-plugin-react-native-web -D
`typescript
import reactNativeWeb from "vite-plugin-react-native-web";
export default defineConfig({
plugins: [reactNativeWeb({ ... })],
});
`
The plugin accepts an options object with the following optional properties:
- enableExpoManualChunk (boolean): When set to true, this option enables manual chunking for expo-modules-core modules to optimize bundle size and loading performance. Default is false. Be cautious when enabling this option, since it overrides user-defined manual chunks in the Vite configuration.
If you are getting errors please report them in the issues section.
The following variables are defined in the transformed files: (inferred during Vite's build process)
- global as globalThis__DEV__
- as process.env.NODE_ENV === 'development'process.env.NODE_ENV
- as process.env.NODE_ENVprocess.env.EXPO_OS
- as "web"
Please feel free to contribute to this project. Just fork it and submit a PR.
MIT
`
``