-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
42 lines (39 loc) · 1.08 KB
/
vite.config.ts
File metadata and controls
42 lines (39 loc) · 1.08 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
import react from "@vitejs/plugin-react";
import type EventEmitter from "events";
import http from "http";
import path from "path";
import { ConfigEnv, defineConfig, ProxyOptions, UserConfig } from "vite";
const proxyConfig: ProxyOptions = {
// Only for development
configure: (proxy: EventEmitter, options: ProxyOptions): void => {
options.rewrite = (path: string): string => {
const proxyURL: URL = new URL(path, "file:");
const url: URL = new URL(proxyURL.searchParams.get("url"));
options.target = url.origin;
return url.pathname + url.search;
};
proxy.on("proxyReq", (proxyReq: http.ClientRequest): void => {
proxyReq.removeHeader("Origin");
});
},
secure: false,
};
export default defineConfig((config: ConfigEnv): UserConfig => {
return {
build: {
outDir: config.isSsrBuild ? "dist-ssr" : undefined,
},
plugins: [react()],
server: {
proxy: {
"/api/proxy": proxyConfig,
"/api/rpc": proxyConfig,
},
},
resolve: {
alias: {
"~": path.resolve("src"),
},
},
};
});