-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathvite.config.ts
46 lines (41 loc) · 981 Bytes
/
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
import { defineConfig, UserConfig } from 'vite'
import tsconfigPaths from 'vite-tsconfig-paths'
import react from '@vitejs/plugin-react'
import { execSync } from 'child_process'
export const commonConfig: UserConfig = {
plugins: [react(), tsconfigPaths()],
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
build: {
rollupOptions: {
external: ['/env'],
},
outDir: 'build',
sourcemap: true,
},
}
export default defineConfig(({ mode }) => {
const commitHash = execSync('git describe --always').toString().trimEnd()
process.env.VITE_APP_RELEASE = `g${commitHash}`
if (mode !== 'development') {
return commonConfig
}
const target = 'http://localhost:8080'
return {
...commonConfig,
...{
server: {
port: 3000,
proxy: {
'/api': { target, changeOrigin: true },
'/env': { target, changeOrigin: true },
},
},
},
}
})