-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.ts
48 lines (46 loc) · 1.29 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
import { defineConfig, loadEnv, type UserConfig } from 'vite'
import path from 'node:path'
import react from '@vitejs/plugin-react'
import fs from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import { createHtmlPlugin } from 'vite-plugin-html'
export default defineConfig(async ({ command, mode }) => {
const env = loadEnv(mode, process.cwd())
let server = {}
if (command === 'serve') {
const devProxyConfigPath = fileURLToPath(
new URL('./dev.proxy.config.js', import.meta.url)
)
try {
await fs.access(devProxyConfigPath)
const devProxyConfig = await import(devProxyConfigPath)
server = {
proxy: devProxyConfig.default,
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
console.log('No proxy configuration found, skipping proxy setup.')
}
}
return {
plugins: [
react(),
createHtmlPlugin({
minify: true,
inject: {
data: {
title: env.VITE_APP_TITLE || 'LLM Alchemist',
favicon:
env.VITE_APP_FAVICON_URL || env.VITE_APP_LOGO_URL || '/logo.svg',
},
},
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
server,
} as UserConfig
})