-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvite.config.ts
90 lines (87 loc) · 2.11 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
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
80
81
82
83
84
85
86
87
88
89
90
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import replace from '@rollup/plugin-replace';
import { string } from 'rollup-plugin-string';
import * as path from 'path';
import * as fs from 'fs';
const getAuthEndpoint = () => {
switch (process.env.NODE_ENV) {
case 'local':
return 'https://auth.test.zhishuyun.com';
case 'test':
return 'https://auth.test.zhishuyun.com';
case 'production':
default:
return 'https://auth.zhishuyun.com';
}
};
const getDataEndpoint = () => {
switch (process.env.NODE_ENV) {
case 'local':
return 'http://127.0.0.1:8007';
case 'test':
return 'https://data.test.zhishuyun.com';
case 'production':
default:
return 'https://data.zhishuyun.com';
}
};
export default defineConfig({
server: {
host: 'chat.local.zhishuyun.com',
port: 443,
https: {
key: fs.readFileSync('certs/chat.local.zhishuyun.com.cert.key'),
cert: fs.readFileSync('certs/chat.local.zhishuyun.com.cert.crt')
},
proxy: {
'/api/v1/me': {
target: getAuthEndpoint(),
changeOrigin: true
},
'/api/v1/token': {
target: getAuthEndpoint(),
changeOrigin: true
},
'/api': {
target: getDataEndpoint(),
changeOrigin: true
},
'/static': {
target: getDataEndpoint(),
changeOrigin: true
}
}
},
plugins: [
vue(),
string({
include: ['**/*.md', '**/*.tpl', '**/*.theme']
}),
replace({
preventAssignment: true
})
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src')
}
},
build: {
sourcemap: false,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
if (id.includes('@fortawesome')) {
const part = id.toString().split('node_modules/')[1];
const parts = part.split('/');
return `${parts[0]}.${parts[1]}`;
}
return id.toString().split('node_modules/')[1].split('/')[0].toString();
}
}
}
}
}
});