o2o-infinith-frontend/vite.config.ts

37 lines
1.1 KiB
TypeScript

import path from 'node:path'
import tailwindcss from '@tailwindcss/vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
export default defineConfig(() => {
// Docker on macOS/Windows에서 파일 변경 감지를 위해 polling 필요
// CHOKIDAR_USEPOLLING=true 환경변수가 있을 때만 켬 (로컬 dev에선 비활성)
const usePolling = process.env.CHOKIDAR_USEPOLLING === 'true'
// Docker 안에서 dev 서버가 돌면 호스트의 localhost는 host.docker.internal로 접근해야 함
// VITE_API_TARGET 환경변수로 오버라이드 가능
const apiTarget =
process.env.VITE_API_TARGET ??
(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,
},
},
},
}
})