-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
132 lines (131 loc) · 4.67 KB
/
vite.config.ts
File metadata and controls
132 lines (131 loc) · 4.67 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import svgr from 'vite-plugin-svgr';
// 192.168.0.104
// 192.168.1.89
const TestTarget = 'localhost:5654';
const TestSecurity = '';
export default defineConfig({
plugins: [
react(),
svgr({
svgrOptions: {
exportType: 'named',
namedExport: 'ReactComponent',
},
include: '**/*.svg?react',
}),
],
resolve: {
alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
},
build: {
chunkSizeWarningLimit: 10000,
target: 'es2020',
sourcemap: false,
},
base: '/web/ui',
server: {
proxy: {
'https://machbase.com/assets/example/*': {
target: `http${TestSecurity}://${TestTarget}`,
changeOrigin: true,
secure: false,
},
'/web/geomap': {
target: `http${TestSecurity}://${TestTarget}`,
changeOrigin: true,
secure: false,
ws: false,
configure: (proxy, options) => {
console.log(options);
proxy.on('proxyReq', (proxyReq, req, res) => {
console.log(`geomap - Proxying request to: ${req.url}`);
});
proxy.on('proxyRes', (proxyRes, req, res) => {
console.log(`geomap - Received response from: ${req.url}`);
});
proxy.on('error', (err, req, res) => {
console.error(`geomap - Proxy error: ${err.message}`);
});
},
},
'/web/echarts': {
target: `http${TestSecurity}://${TestTarget}`,
changeOrigin: true,
secure: false,
ws: false,
configure: (proxy, options) => {
console.log(options);
proxy.on('proxyReq', (proxyReq, req, res) => {
console.log(`echarts - Proxying request to: ${req.url}`);
});
proxy.on('proxyRes', (proxyRes, req, res) => {
console.log(`echarts - Received response from: ${req.url}`);
});
proxy.on('error', (err, req, res) => {
console.error(`echarts - Proxy error: ${err.message}`);
});
},
},
'/web/api': {
target: `http${TestSecurity}://${TestTarget}`,
changeOrigin: true,
secure: false,
ws: false,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
configure: (proxy, options) => {
proxy.on('error', function (err, req, res) {
if (req.url === '/web/api/tql' && req.method === 'POST') {
res.writeHead(401, {
'Content-Type': 'application/json; charset=utf-8',
});
res.end('{"reason":"token is expired by 6.3134028s","success":false}');
}
});
},
},
'/web/apps': {
target: `http${TestSecurity}://${TestTarget}`,
changeOrigin: true,
secure: false,
ws: false,
},
'/web/machbase': {
target: `http${TestSecurity}://${TestTarget}`,
changeOrigin: true,
secure: false,
ws: false,
},
'/web/tutorials': {
target: `http${TestSecurity}://${TestTarget}`,
changeOrigin: true,
secure: false,
ws: false,
},
'/web/api/term': {
target: `ws${TestSecurity}://${TestTarget}`,
changeOrigin: true,
secure: false,
ws: true,
},
'/web/api/console': {
target: `ws${TestSecurity}://${TestTarget}`,
changeOrigin: true,
secure: false,
ws: true,
},
'/db/tql': {
target: `http${TestSecurity}://${TestTarget}`,
changeOrigin: true,
secure: false,
},
'/db/query': {
target: `http${TestSecurity}://${TestTarget}`,
changeOrigin: true,
secure: false,
},
},
},
});