-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
53 lines (50 loc) · 1.47 KB
/
vite.config.ts
File metadata and controls
53 lines (50 loc) · 1.47 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
import path from 'path'
import { defineConfig, loadEnv } from 'vite'
import type { ViteDevServer } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { devConsoleCapture } from './src/plugins/dev-console-capture'
const addHealthCheck = (server: ViteDevServer) => {
server.middlewares.use('/api/healthz', (_req, res) => {
res.statusCode = 200
res.end('ok')
})
}
// https://vite.dev/config/
export default defineConfig(({ mode }) => {
// Load env file based on `mode` in the current working directory.
const env = loadEnv(mode, process.cwd(), '')
const apiTarget = env.MAJOR_API_BASE_URL || 'https://api.prod.major.build'
return {
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
plugins: [
react(),
{
name: 'health-check',
configureServer(server) {
addHealthCheck(server)
},
},
// DO NOT REMOVE: Used by major AI to capture console logs during development only
devConsoleCapture(),
],
server: {
proxy: {
'/api': {
target: apiTarget,
changeOrigin: true,
secure: false,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
define: {
// Use local proxy in development
'import.meta.env.MAJOR_API_BASE_URL': JSON.stringify(mode === 'development' ? '/api' : apiTarget),
'import.meta.env.MAJOR_JWT_TOKEN': JSON.stringify(env.MAJOR_JWT_TOKEN || ''),
},
}
})