34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
|
import { defineConfig } from 'vite'
|
||
|
import react from '@vitejs/plugin-react'
|
||
|
import path from 'path'
|
||
|
|
||
|
export default defineConfig({
|
||
|
plugins: [react()],
|
||
|
resolve: {
|
||
|
alias: {
|
||
|
'@': path.resolve(__dirname, './src'),
|
||
|
// React Native Web 别名配置
|
||
|
'react-native$': 'react-native-web',
|
||
|
'react-native/Libraries/EventEmitter/RCTDeviceEventEmitter$': 'react-native-web/dist/vendor/react-native/NativeEventEmitter/RCTDeviceEventEmitter',
|
||
|
'react-native/Libraries/vendor/emitter/EventEmitter$': 'react-native-web/dist/vendor/react-native/emitter/EventEmitter',
|
||
|
'react-native/Libraries/EventEmitter/NativeEventEmitter$': 'react-native-web/dist/vendor/react-native/NativeEventEmitter',
|
||
|
},
|
||
|
extensions: ['.web.tsx', '.web.ts', '.web.jsx', '.web.js', '.tsx', '.ts', '.jsx', '.js'],
|
||
|
},
|
||
|
define: {
|
||
|
// React Native Web 需要的全局变量
|
||
|
global: 'globalThis',
|
||
|
__DEV__: JSON.stringify(process.env.NODE_ENV !== 'production'),
|
||
|
},
|
||
|
server: {
|
||
|
port: 3000,
|
||
|
host: true,
|
||
|
},
|
||
|
build: {
|
||
|
outDir: 'dist',
|
||
|
sourcemap: true,
|
||
|
},
|
||
|
optimizeDeps: {
|
||
|
include: ['react-native-web'],
|
||
|
},
|
||
|
})
|