-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
67 lines (65 loc) · 1.69 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import {defineConfig, transformWithEsbuild} from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import svgr from 'vite-plugin-svgr';
import babel from 'vite-plugin-babel';
export default defineConfig({
define: {
global: 'window',
'process.env': {},
__DEV__: 'false',
},
optimizeDeps: {
disabled: false,
esbuildOptions: {
mainFields: ['module', 'main'],
resolveExtensions: ['.web.js', '.js', '.ts'],
jsx: 'automatic',
loader: {
'.js': 'jsx',
},
},
},
resolve: {
extensions: ['.web.tsx', '.web.jsx', '.web.js', '.tsx', '.ts', '.js'],
alias: {
'react-native': 'react-native-web',
'react-native-svg': 'react-native-svg-web',
'@ui-library': path.resolve(__dirname, './ui-library'),
},
},
plugins: [
{
name: 'treat-js-files-as-jsx',
async transform(code, id) {
if (!id.match(/src\/.*\.js$/)) return null; // include ts or tsx for TypeScript support
// Use the exposed transform from vite, instead of directly
// transforming with esbuild
return transformWithEsbuild(code, id, {
loader: 'jsx',
jsx: 'automatic',
});
},
},
svgr(),
react(),
babel({
filter:
/[\/](node_modules\/@react-navigation|node_modules\/react-native-drawer-layout)[\/].+\.(js|ts|jsx|tsx)$/,
babelConfig: {
babelrc: false,
configFile: false,
plugins: [
'@babel/plugin-proposal-export-namespace-from',
'react-native-reanimated/plugin',
],
},
}),
],
build: {
commonjsOptions: {
include: [],
transformMixedEsModules: true,
},
},
});