This repository has been archived by the owner on May 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
87 lines (83 loc) · 2.15 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/// <reference types="vitest" />
/// <reference types="vite/client" />
/// <reference types="vitest/config" />
import { defineConfig, UserConfigExport } from 'vite'
import react from '@vitejs/plugin-react'
import { visualizer } from 'rollup-plugin-visualizer'
// https://vitejs.dev/config/
let options: UserConfigExport = {
plugins: [react(), visualizer()],
test: {
globals: true,
environment: 'jsdom',
setupFiles: './src/test/setup.ts',
css: true,
coverage: {
provider: 'c8'
}
},
server: {
port: 8080,
host: "0.0.0.0"
},
preview: {
port: 8080
},
resolve: {
alias:[
{
find: 'wagmi/dist',
replacement:'wagmi/dist'
},
{
find: './dist/connectors/walletConnect',
replacement:'wagmi/dist/connectors/walletConnect.js'
},
{
find: 'bn.js',
replacement:'node_modules/bn.js/lib/bn.js'
}
]
}
}
const env = process.env.NODE_ENV
const resolve = {
alias:[
{
find: 'wagmi/dist',
replacement:'wagmi/dist'
},
{
find: './dist/connectors/walletConnect',
replacement:'wagmi/dist/connectors/walletConnect.js'
},
{
find: 'bn.js',
replacement:'node_modules/bn.js/lib/bn.js'
},
{
find: 'tslib',
replacement: 'node_modules/tslib/tslib.js'
},
{
find: '@walletconnect/window-metadata',
replacement: 'node_modules/window-metadata/dist/cjs/index.js'
},
{
find: 'query-string',
replacement: 'node_modules/query-string/index.js'
}
]
}
/**
* 不知道为啥在开发模式下修改Buffer的依赖路径会报错,
* 所以只能在构建的时候加上
*/
if (env === 'production') {
resolve.alias = [{
find: 'buffer',
replacement:'node_modules/buffer/index.js',
},...resolve.alias]
}
options.resolve = resolve
export default defineConfig(options)