-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.ts
111 lines (109 loc) · 4.2 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
import nodePolyfills from 'rollup-plugin-polyfill-node'
import { resolve } from 'path'
import Components from 'unplugin-vue-components/vite'
import { NaiveUiResolver, VueUseComponentsResolver } from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
// 根据当前工作目录中的 `mode` 加载 .env 文件
const env = loadEnv(mode, process.cwd())
return {
plugins: [
vue(),
vueJsx(),
Components({
resolvers: [NaiveUiResolver(), VueUseComponentsResolver()],
directoryAsNamespace: true,
}),
],
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
base: env.VITE_PUBLIC_PATH, // 设置打包路径
server: {
port: 4040, // 服务启动端口号
open: true, // 服务启动时自动打开浏览器
cors: true, // 允许跨域
// 设置代理
proxy: {
'/backend/cosmostation': {
target: 'https://api-utility.cosmostation.io',
changeOrigin: true,
rewrite: path => path.replace(/^\/backend\/cosmostation/, ''),
},
'/backend/ibccoin': {
// target: 'http://127.0.0.1:4523/mock/767404',
target: 'http://135.181.25.194:7777',
changeOrigin: true,
rewrite: path => path.replace(/^\/backend\/ibccoin/, ''),
},
'/backend/cosmosNetwork': {
target: 'https://api.cosmos.network',
changeOrigin: true,
rewrite: path => path.replace(/^\/backend\/cosmosNetwork/, ''),
},
'/backend/juno': {
target: 'https://lcd-juno.itastakers.com',
changeOrigin: true,
rewrite: path => path.replace(/^\/backend\/juno/, ''),
},
'/backend/osmosis': {
target: 'https://proxy.atomscan.com',
changeOrigin: true,
rewrite: path => path.replace(/^\/backend\/osmosis/, ''),
},
'/backend/evmos': {
target: 'https://rest.bd.evmos.org:1317',
changeOrigin: true,
rewrite: path => path.replace(/^\/backend\/evmos/, ''),
},
'/backend/assetmantle': {
target: 'https://rest.assetmantle.one',
changeOrigin: true,
rewrite: path => path.replace(/^\/backend\/assetmantle/, ''),
},
'/backend/crescent': {
target: 'https://api.crescent.pupmos.network',
changeOrigin: true,
rewrite: path => path.replace(/^\/backend\/crescent/, ''),
},
},
},
build: {
rollupOptions: {
plugins: [nodePolyfills()],
},
commonjsOptions: {
transformMixedEsModules: true,
exclude: ['node_modules/naive-ui/**', 'node_modules/lodash-es/**', 'node_modules/@types/lodash-es/**'],
},
minify: 'terser',
terserOptions: {
compress: {
//生产环境时移除console
drop_console: true,
drop_debugger: true,
},
},
},
optimizeDeps: {
esbuildOptions: {
// Node.js global to browser globalThis
define: {
global: 'globalThis',
},
// Enable esbuild polyfill plugins
plugins: [
NodeGlobalsPolyfillPlugin({
buffer: true,
}),
],
},
},
}
})