-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathvite.config.js
73 lines (71 loc) · 2.22 KB
/
vite.config.js
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
// vite.config.js
import { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
import NodePolyfills from 'rollup-plugin-polyfill-node';
export default defineConfig(() => {
return {
plugins: [
vue(),
NodeGlobalsPolyfillPlugin({
process: true,
buffer: true,
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
buffer: require.resolve('buffer/'), // ensure this is resolving to the correct location
stream: require.resolve('stream-browserify'), // using stream-browserify as a polyfill
}
},
optimizeDeps: {
esbuildOptions: {
plugins: [
NodeGlobalsPolyfillPlugin({
process: true,
buffer: true,
}),
],
define: {
global: 'globalThis',
},
},
},
define: {
'process.env': {},
global: 'globalThis',
'APP_VERSION': JSON.stringify(require('./package.json').version),
},
build: {
rollupOptions: {
plugins: [
NodePolyfills(),
],
},
},
server: {
port: 8080,
proxy: {
'/api': {
target: 'http://localhost:26640',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
},
'/rpc': {
target: 'http://localhost:26657',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/rpc/, ''),
ws: true
},
'/websocket': {
target: 'http://localhost:26657',
changeOrigin: true,
ws: true,
upgrade: true
}
}
}
};
});