-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
79 lines (72 loc) · 1.9 KB
/
Copy pathvite.config.js
File metadata and controls
79 lines (72 loc) · 1.9 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
78
79
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import fs from 'node:fs'
import path from 'node:path'
function readMaybe(filePath) {
try {
if (!filePath) return undefined
const p = path.isAbsolute(filePath) ? filePath : path.resolve(process.cwd(), filePath)
return fs.readFileSync(p)
} catch {
return undefined
}
}
function resolveHttps() {
const enabled = String(process.env.VITE_DEV_HTTPS || '').toLowerCase()
if (!['1', 'true', 'yes', 'on'].includes(enabled)) return false
const key = readMaybe(process.env.VITE_DEV_HTTPS_KEY)
const cert = readMaybe(process.env.VITE_DEV_HTTPS_CERT)
const ca = readMaybe(process.env.VITE_DEV_HTTPS_CA)
if (key && cert) return { key, cert, ca }
return true
}
function resolveAllowedHosts() {
const fromEnv = String(process.env.VITE_ALLOWED_HOSTS || '')
.split(',')
.map(s => s.trim())
.filter(Boolean)
const base = ['test111.moonpeach.top']
return Array.from(new Set([...base, ...fromEnv]))
}
// https://vite.dev/config/
export default defineConfig({
base: './',
plugins: [vue()],
server: {
port: 5174,
https: resolveHttps(),
allowedHosts: resolveAllowedHosts(),
proxy: {
'/api': {
target: 'http://127.0.0.1:5000',
changeOrigin: true,
ws: true
}
}
},
preview: {
port: 5174,
https: resolveHttps(),
allowedHosts: resolveAllowedHosts()
},
build: {
// Increase warning limit to 1000KB
chunkSizeWarningLimit: 1000,
rollupOptions: {
output: {
// Separate large third-party libraries into independent chunks
manualChunks(id) {
if (id.includes('node_modules')) {
if (id.includes('naive-ui')) {
return 'naive-ui'
}
if (id.includes('@vicons')) {
return 'icons'
}
return 'vendor'
}
}
}
}
}
})