-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.dev.ts
72 lines (66 loc) · 1.94 KB
/
vite.dev.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
68
69
70
71
72
import { defineConfig, splitVendorChunkPlugin } from 'vite'
import { resolve } from 'path'
import react from '@vitejs/plugin-react'
import GlobalsPolyfills from '@esbuild-plugins/node-globals-polyfill'
import NodeModulesPolyfills from '@esbuild-plugins/node-modules-polyfill'
import { truncate } from 'fs/promises';
import nodePolyfills from "rollup-plugin-polyfill-node";
import path from "path";
import {visualizer} from "rollup-plugin-visualizer"
// https://vitejs.dev/config/
// https://github.com/vitejs/vite/issues/1973
// on going issues with vite's global and process
export default defineConfig({
base: "./",
server: {
hmr: (process.env.GITPOD_WORKSPACE_URL && (process.env.GITPOD_REMOTE_CLI_IPC)) ? {
host: process.env.GITPOD_WORKSPACE_URL.replace("https://", "3000-"),
protocol: "wss",
clientPort: 443
} : true
},
resolve: {
dedupe: ["buffer","bn.js", "keccak", "ethers"],
},
plugins: [
visualizer(),
react(),
],
esbuild: {
jsxFactory: 'jsx',
jsxInject: `import {jsx} from '@emotion/react'`
},
define: {
global: 'globalThis'
},
publicDir: "./res",
build: {
target: ["esnext"],
rollupOptions: {
plugins: [nodePolyfills({include: ['util']})],
output: {
manualChunks: {
"mui" : ["@mui/material"],
"ethers":["ethers"],
}
}
},
},
optimizeDeps: {
esbuildOptions: {
target: "esnext",
// Node.js global to browser globalThis
define: {
global: 'globalThis'
},
treeShaking: true,
// Enable esbuild polyfill plugins
plugins: [
GlobalsPolyfills({
buffer: true,
process: true,
}),
]
}
}
})