-
Notifications
You must be signed in to change notification settings - Fork 143
Expand file tree
/
Copy pathvite.config.js
More file actions
42 lines (39 loc) · 1.12 KB
/
vite.config.js
File metadata and controls
42 lines (39 loc) · 1.12 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
import { defineConfig } from 'vite'
import { devApiPlugin } from './scripts/dev-api.js'
import fs from 'fs'
import path from 'path'
import { homedir } from 'os'
// 读取 package.json 版本号,构建时注入前端
const pkg = JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url), 'utf8'))
// 读取 Gateway 端口(启动时读取一次)
let gatewayPort = 18789
try {
const cfg = JSON.parse(fs.readFileSync(path.join(homedir(), '.openclaw', 'openclaw.json'), 'utf8'))
gatewayPort = cfg?.gateway?.port || 18789
} catch {}
export default defineConfig({
plugins: [devApiPlugin()],
define: {
__APP_VERSION__: JSON.stringify(pkg.version),
},
clearScreen: false,
server: {
port: 1420,
strictPort: true,
proxy: {
'/ws': {
target: `ws://127.0.0.1:${gatewayPort}`,
ws: true,
configure: (proxy) => {
proxy.on('error', () => {})
},
},
},
},
envPrefix: ['VITE_', 'TAURI_'],
build: {
target: ['es2021', 'chrome100', 'safari13'],
minify: !process.env.TAURI_DEBUG ? 'esbuild' : false,
sourcemap: !!process.env.TAURI_DEBUG,
},
})