-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
64 lines (62 loc) · 2.08 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
import { defineConfig } from "vite";
import viteReactPlugin from "@vitejs/plugin-react";
import viteBasicSSLPlugin from "@vitejs/plugin-basic-ssl";
import { statusEndpointServerHook } from "./server/statusEndpointServerHook";
import { searchEndpointServerHook } from "./server/searchEndpointServerHook";
import { compressionServerHook } from "./server/compressionServerHook";
import { crossOriginServerHook } from "./server/crossOriginServerHook";
import { cacheServerHook } from "./server/cacheServerHook";
import { getSearchToken, regenerateSearchToken } from "./server/searchToken";
export default defineConfig(({ command }) => {
if (command === "build") {
regenerateSearchToken();
}
return {
root: "./client",
define: {
VITE_SEARCH_TOKEN: JSON.stringify(getSearchToken()),
},
server: {
host: process.env.HOST,
port: process.env.PORT ? Number(process.env.PORT) : undefined,
hmr: {
port: process.env.HMR_PORT ? Number(process.env.HMR_PORT) : undefined,
},
},
preview: {
host: process.env.HOST,
port: process.env.PORT ? Number(process.env.PORT) : undefined,
},
build: {
target: "esnext",
},
plugins: [
process.env.BASIC_SSL === "true" ? viteBasicSSLPlugin() : undefined,
viteReactPlugin(),
{
name: "configure-server-compression",
configureServer: compressionServerHook,
configurePreviewServer: compressionServerHook,
},
{
name: "configure-server-cross-origin-isolation",
configureServer: crossOriginServerHook,
configurePreviewServer: crossOriginServerHook,
},
{
name: "configure-server-search-endpoint",
configureServer: searchEndpointServerHook,
configurePreviewServer: searchEndpointServerHook,
},
{
name: "configure-server-status-endpoint",
configureServer: statusEndpointServerHook,
configurePreviewServer: statusEndpointServerHook,
},
{
name: "configure-server-cache",
configurePreviewServer: cacheServerHook,
},
],
};
});