-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathvite.config.ts
More file actions
49 lines (45 loc) · 1.47 KB
/
vite.config.ts
File metadata and controls
49 lines (45 loc) · 1.47 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
import { ProxyOptions, defineConfig, loadEnv } from "vite";
import topLevelAwait from "vite-plugin-top-level-await";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
const simplexTarget = env.VITE_SIMPLEX_TARGET || "http://localhost:8000";
// proxy config for half-duplex (11236)
const proxyConf: Record<string, string | ProxyOptions> = {
"/api/simplex": {
target: simplexTarget,
changeOrigin: true,
ws: true,
secure: false,
rewrite: (path) => path.replace(/^\/api\/simplex/, '/api/chat'),
configure: (proxy, _options) => {
proxy.on('error', (err, _req, _res) => {
console.log('proxy error (simplex)', err);
});
proxy.on('proxyReq', (proxyReq, req, _res) => {
console.log('Sending Request to Simplex:', req.method, req.url);
});
proxy.on('proxyRes', (proxyRes, req, _res) => {
console.log('Received Response from Simplex:', proxyRes.statusCode, req.url);
});
},
},
};
return {
server: {
host: "0.0.0.0",
port: 8010,
https: false,
proxy: {
...proxyConf,
}
},
plugins: [
topLevelAwait({
// The export name of top-level await promise for each chunk module
promiseExportName: "__tla",
// The function to generate import names of top-level await promise in each chunk module
promiseImportName: i => `__tla_${i}`,
}),
],
};
});