-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrsbuild.config.js
More file actions
77 lines (74 loc) · 2.43 KB
/
Copy pathrsbuild.config.js
File metadata and controls
77 lines (74 loc) · 2.43 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
import { defineConfig, loadEnv } from '@rsbuild/core'
import { pluginReact } from '@rsbuild/plugin-react'
import { pluginNodePolyfill } from '@rsbuild/plugin-node-polyfill'
export default defineConfig(({ env }) => {
const envVars = loadEnv({
mode: env.envMode,
prefixes: ['PUBLIC_'],
})
const openAIBaseUrl = envVars.parsed.PUBLIC_OPENAI_BASE_URL || process.env.PUBLIC_OPENAI_BASE_URL
const glmBaseUrl = envVars.parsed.PUBLIC_GLM_BASE_URL || process.env.PUBLIC_GLM_BASE_URL
const modelscopeBaseUrl =
envVars.parsed.PUBLIC_MODELSCOPE_BASE_URL || process.env.PUBLIC_MODELSCOPE_BASE_URL
const kimiBaseUrl = envVars.parsed.PUBLIC_KIMI_BASE_URL || process.env.PUBLIC_KIMI_BASE_URL
// Base path for GitHub Pages (set to "/Qurio/" for project page). Allow override via env.
// In development, use root path to avoid issues with chunk loading
const isDev = env.mode === 'development'
const assetPrefix = isDev ? '/' : process.env.PUBLIC_BASE_PATH || '/Qurio/'
return {
plugins: [pluginReact(), pluginNodePolyfill()],
html: {
template: './index.html',
},
output: {
assetPrefix,
},
source: {
entry: {
index: './src/main.jsx',
},
define: {
...envVars.publicVars,
},
alias: {
'@': './src',
},
},
server: {
host: '0.0.0.0',
proxy:
openAIBaseUrl || glmBaseUrl || modelscopeBaseUrl || kimiBaseUrl
? {
...(openAIBaseUrl && {
'/api/openaiCompatible': {
target: openAIBaseUrl,
changeOrigin: true,
pathRewrite: { '^/api/openaiCompatible': '' },
},
}),
...(glmBaseUrl && {
'/api/glm': {
target: glmBaseUrl,
changeOrigin: true,
pathRewrite: { '^/api/glm': '' },
},
}),
...(modelscopeBaseUrl && {
'/api/modelscope': {
target: modelscopeBaseUrl,
changeOrigin: true,
pathRewrite: { '^/api/modelscope': '' },
},
}),
...(kimiBaseUrl && {
'/api/kimi': {
target: kimiBaseUrl,
changeOrigin: true,
pathRewrite: { '^/api/kimi': '' },
},
}),
}
: undefined,
},
}
})