This repository has been archived by the owner on Jun 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.ts
72 lines (71 loc) · 1.68 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
68
69
70
71
72
import GlobalPolyFill from '@esbuild-plugins/node-globals-polyfill';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import viteMarkdown, { Mode } from 'vite-plugin-markdown';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), viteMarkdown({ mode: [Mode.HTML] })],
build: {
target: 'esnext',
sourcemap: false,
commonjsOptions: {
transformMixedEsModules: true,
},
rollupOptions: {
// Enable esbuild polyfill plugins
plugins: [
GlobalPolyFill({
buffer: true,
process: process.env.MODE !== 'production',
}),
],
output: {
manualChunks(id: string) {
if (id.includes('wagmi') || id.includes('viem')) {
return 'wagmi';
}
if (id.includes('react') || id.includes('apollo')) {
return 'react';
}
return null;
},
},
},
},
define: {
globalThis: 'window',
},
// resolve: {
// alias: {
// process: 'process/browser',
// '@': path.resolve(__dirname, './src/'),
// },
// },
resolve: {
alias: {
// polyfills
Buffer: 'vite-compatible-readable-buffer',
stream: 'vite-compatible-readable-stream',
util: 'rollup-plugin-node-polyfills/polyfills/util',
},
},
optimizeDeps: {
disabled: false,
esbuildOptions: {
// Node.js global to browser globalThis
define: {
global: 'globalThis',
},
// Enable esbuild polyfill plugins
plugins: [
GlobalPolyFill({
buffer: true,
process: true,
}),
],
},
},
preview: {
port: 3001,
},
});