-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
55 lines (54 loc) · 1.43 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
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
import { NodeGlobalsPolyfillPlugin } from "@esbuild-plugins/node-globals-polyfill";
import { NodeModulesPolyfillPlugin } from "@esbuild-plugins/node-modules-polyfill";
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), "");
return {
define: {
__APP_ENV__: env.APP_ENV,
},
plugins: [react()],
optimizeDeps: {
esbuildOptions: {
define: {
global: "globalThis",
},
plugins: [
NodeGlobalsPolyfillPlugin({ process: true, buffer: true }),
// NodeModulesPolyfillPlugin(),
],
},
},
build: {
rollupOptions: {
output: {
manualChunks: (id) => {
const isModule = id.includes("node_modules");
if (isModule && id.includes("@solana")) {
return "vendor_solana";
}
if (isModule && id.includes("@project-serum")) {
return "vendor_anchor";
}
if (isModule && id.includes("@tanstack")) {
return "vendor_tanstack";
}
},
},
},
},
// resolve: {
// alias: [
// {
// find: "stream",
// replacement: `stream-browserify`,
// },
// ],
// },
server: {
port: 9933,
},
};
});