-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathvite.config.ts
56 lines (51 loc) · 1.29 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
/// <reference types="vitest" />
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { TanStackRouterVite } from '@tanstack/router-vite-plugin'
import checker from 'vite-plugin-checker'
import path from 'path'
// @ts-expect-error mode is not defined
export default ({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd(), '') }
const VITE_PORT = process.env.VITE_PORT ?? '3002'
const VITE_HOST = process.env.VITE_HOST ?? 'localhost'
const API_URL = process.env.API_URL
if (API_URL == null) {
throw new Error('API_URL need to be defined')
}
// https://vitejs.dev/config/
return defineConfig({
plugins: [
react(),
checker({
typescript: false,
}),
// basicSsl(),
TanStackRouterVite(),
],
test: {
environment: 'happy-dom',
globals: true,
setupFiles: './src/__tests__/setup.ts'
},
server: {
host: `${VITE_HOST}`,
port: +`${VITE_PORT}`,
proxy: {
'/api': {
target: API_URL,
changeOrigin: true,
},
},
watch: { usePolling: true },
},
css: {
transformer: 'lightningcss',
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
})
}