-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathvite.config.ts
More file actions
94 lines (91 loc) · 2.46 KB
/
Copy pathvite.config.ts
File metadata and controls
94 lines (91 loc) · 2.46 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import { defineConfig } from "vite";
import { cjsInterop } from "vite-plugin-cjs-interop";
import reactNativeWeb from "vite-plugin-react-native-web";
import tsConfigPaths from "vite-tsconfig-paths";
const rnwWebExtensions = [
".web.mjs",
".web.js",
".web.jsx",
".web.ts",
".web.tsx",
".mjs",
".js",
".jsx",
".ts",
".tsx",
".json",
];
// Esbuild plugin to stub react-native/Libraries/* deep imports
// These are native-only and don't exist in react-native-web
const stubReactNativeInternals = {
name: "stub-react-native-internals",
setup(build: { onResolve: Function; onLoad: Function }) {
build.onResolve({ filter: /^react-native\/Libraries\// }, () => ({
path: "rn-stub",
namespace: "rn-stub",
}));
build.onLoad({ filter: /.*/, namespace: "rn-stub" }, () => ({
contents: "export default undefined; export {}",
loader: "js" as const,
}));
},
};
export default defineConfig({
server: {
port: 1337,
},
preview: {
host: "127.0.0.1",
},
plugins: [
tsConfigPaths({ projects: ["./tsconfig.json"] }),
tanstackStart({
srcDirectory: "src",
router: { routesDirectory: "app" },
// spa: { enabled: true },
prerender: {
enabled: true,
autoSubfolderIndex: true,
crawlLinks: true,
failOnError: true,
filter: (page) =>
!page.path.match(/\.(pdf|zip|vcf|xml|ico|txt|json)$/),
},
}),
reactNativeWeb(),
cjsInterop({
dependencies: ["inline-style-prefixer", "inline-style-prefixer/**"],
}),
],
ssr: {
noExternal: [
"react-native",
"react-native-web",
"react-native-svg",
"react-native-reanimated",
"react-native-safe-area-context",
"react-native-gesture-handler",
"react-native-worklets",
"@react-native-async-storage/async-storage",
"@react-native-clipboard/clipboard",
],
optimizeDeps: {
exclude: ["react", "react-dom"],
include: [
"react-native-svg",
"react-native-reanimated",
"react-native-safe-area-context",
"react-native-gesture-handler",
"react-native-worklets",
"@react-native-clipboard/clipboard",
"@react-native-async-storage/async-storage",
],
esbuildOptions: {
mainFields: ["module", "main"],
resolveExtensions: rnwWebExtensions,
plugins: [stubReactNativeInternals],
},
},
},
});