38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import path from 'node:path'
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), '')
|
|
|
|
// Docker on macOS/Windows에서 파일 변경 감지를 위해 polling 필요
|
|
// CHOKIDAR_USEPOLLING=true 환경변수가 있을 때만 켬 (로컬 dev에선 비활성)
|
|
const usePolling = process.env.CHOKIDAR_USEPOLLING === 'true'
|
|
|
|
const apiTarget =
|
|
env.VITE_API_TARGET ||
|
|
env.VITE_API_BASE_URL ||
|
|
(usePolling ? 'http://host.docker.internal:8001' : 'http://localhost:8001')
|
|
|
|
return {
|
|
plugins: [react(), tailwindcss()],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
},
|
|
},
|
|
server: {
|
|
port: 3000,
|
|
host: '0.0.0.0',
|
|
watch: usePolling ? { usePolling: true, interval: 300 } : undefined,
|
|
proxy: {
|
|
'/api': {
|
|
target: apiTarget,
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
})
|