-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
57 lines (53 loc) · 1.23 KB
/
vite.config.js
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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import Unocss from 'duxweb-cli/plugins/unocss'
import duxweb from 'duxweb-cli/plugins/duxweb'
import { resolve } from 'path'
import fs from 'fs'
import { parse } from 'yaml'
const requestConfig = (() => {
let config = {}
const url = './config/use.yaml'
const devUrl = './config/use.dev.yaml'
if (fs.existsSync(devUrl)) {
config = parse(fs.readFileSync(devUrl, { encoding: 'utf8' }))
} else if (fs.existsSync(url)) {
config = parse(fs.readFileSync(url, { encoding: 'utf8' }))
}
// use 只读取链接地址
if (config.app) {
config = {
domain: config.app.domain,
websocket: config.app.websocket
}
}
return config
})();
// https://vitejs.dev/config/
export default defineConfig({
root: resolve(__dirname, 'client'),
base: '/client/',
plugins: [
react(),
duxweb(),
Unocss()
],
publicDir: false,
resolve: {
alias: {
'@/app': resolve(__dirname, 'client/app')
}
},
build: {
outDir: resolve(__dirname, 'public/client'),
},
server: {
proxy: {
'^/(?!client\\b).*': requestConfig.domain,
'^/ws': {
target: requestConfig.websocket,
ws: true,
}
}
}
})