2026-09-05 21:10:18 +00:00
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
|
import tailwindcss from '@tailwindcss/vite'
|
2026-09-10 00:32:22 +00:00
|
|
|
import fs from 'node:fs'
|
|
|
|
|
import path from 'node:path'
|
|
|
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
|
|
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
|
|
|
|
|
|
|
|
function getAppVersion(): string {
|
|
|
|
|
if (process.env.VITE_APP_VERSION) {
|
|
|
|
|
return process.env.VITE_APP_VERSION
|
|
|
|
|
}
|
|
|
|
|
const candidatePaths = [
|
|
|
|
|
path.resolve(__dirname, '../version.ini'),
|
|
|
|
|
path.resolve(__dirname, 'version.ini'),
|
|
|
|
|
path.resolve(process.cwd(), '../version.ini'),
|
|
|
|
|
path.resolve(process.cwd(), 'version.ini'),
|
|
|
|
|
]
|
|
|
|
|
for (const p of candidatePaths) {
|
|
|
|
|
if (fs.existsSync(p)) {
|
|
|
|
|
try {
|
|
|
|
|
const content = fs.readFileSync(p, 'utf-8')
|
|
|
|
|
const match = content.match(/^version\s*=\s*([^\r\n]+)/m)
|
|
|
|
|
if (match) {
|
|
|
|
|
return match[1].trim().replace(/^["']|["']$/g, '')
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.warn(`Failed to read version from ${p}:`, err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return '1.0'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const appVersion = getAppVersion()
|
2026-09-05 21:10:18 +00:00
|
|
|
|
|
|
|
|
// https://vite.dev/config/
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
plugins: [
|
|
|
|
|
react(),
|
|
|
|
|
tailwindcss(),
|
|
|
|
|
],
|
2026-09-10 00:32:22 +00:00
|
|
|
define: {
|
|
|
|
|
'import.meta.env.VITE_APP_VERSION': JSON.stringify(appVersion),
|
|
|
|
|
},
|
2026-09-05 21:10:18 +00:00
|
|
|
server: {
|
|
|
|
|
port: 5173,
|
|
|
|
|
proxy: {
|
|
|
|
|
'/api': {
|
|
|
|
|
target: 'http://127.0.0.1:8000',
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
},
|
|
|
|
|
'/ws': {
|
|
|
|
|
target: 'ws://127.0.0.1:8000',
|
|
|
|
|
ws: true,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2026-09-10 00:32:22 +00:00
|
|
|
|