-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvite.config.ts
More file actions
55 lines (48 loc) · 2.04 KB
/
vite.config.ts
File metadata and controls
55 lines (48 loc) · 2.04 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
/*
* Copyright (c) Haulmont 2025. All Rights Reserved.
* Use is subject to license terms.
*/
import {defineConfig, loadEnv} from "vite"
import react from "@vitejs/plugin-react"
import {getEngineConfig} from "./src/features/bpm-engine/config.ts";
import type {BpmEngineConfig} from "./src/features/bpm-engine/types.ts";
import path from "path";
// https://vite.dev/config/
export default ({mode}: { mode: string }) => {
process.env = {...process.env, ...loadEnv(mode, process.cwd())};
const engineUrl = process.env.VITE_BPM_ENGINE_API_URL;
const engineType = process.env.VITE_BPM_ENGINE_TYPE;
const engineConfig: BpmEngineConfig = getEngineConfig(engineUrl, engineType);
const engineApiUrl = new URL(engineConfig.apiUrl);
return defineConfig({
plugins: [react()],
server: {
proxy: {
[`${engineApiUrl.pathname}`]: {
target: `${engineApiUrl.origin}`,
changeOrigin: true,
configure: (proxy, _options) => {
proxy.on("proxyRes", (proxyRes, _req, _res) => {
if (proxyRes.statusCode === 401) {
// to hide standard basic auth dialog in browser
delete proxyRes.headers["www-authenticate"];
}
});
}
},
}
},
resolve: {
alias: {
"@assets": path.resolve(__dirname, "./src/assets"),
"@components": path.resolve(__dirname, "./src/components"),
"@features": path.resolve(__dirname, "./src/features"),
"@hooks": path.resolve(__dirname, "./src/hooks"),
"@models": path.resolve(__dirname, "./src/models"),
"@pages": path.resolve(__dirname, "./src/pages"),
"@routes": path.resolve(__dirname, "./src/routes"),
"@utils": path.resolve(__dirname, "./src/utils"),
},
},
});
}