ship-gis/vite.config.ts
htlee 3060973f92 chore: React 19 + Vite 7 + ESLint 9 + Zustand 5 업그레이드
- React 18.2 → 19.2.4, react-dom 19.2.4
- Vite 5.2.10 → 7.3.1, @vitejs/plugin-react 5.1.4
- ESLint 8.44 → 9.39.2 flat config, typescript-eslint 8.55.0
- eslint-plugin-react-hooks 7.0.1 (신규 규칙 warn 설정)
- Zustand 4.5 → 5.0.11 (shallow → useShallow 마이그레이션)
- sass 1.77.8 → 1.97.3
- sockjs-client, flatgeobuf 미사용 패키지 제거
- react-router-dom v7 future flag 적용
- vite.config.ts: defineConfig 함수형, build.target: es2022

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 11:37:37 +09:00

84 lines
2.0 KiB
TypeScript

import { defineConfig, loadEnv, type Plugin } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig(({ mode, command }) => {
const env = loadEnv(mode, process.cwd(), '');
const isLocalDev = mode === 'development';
const isBuild = command === 'build';
const base = env.VITE_BASE_URL || '/';
console.log(`[Vite] Mode: ${mode}, Command: ${command}, Base: ${base}, isLocalDev: ${isLocalDev}`);
const excludePatterns: RegExp[] = isBuild && !isLocalDev
? [
/[/\\]publish[/\\]/,
/[/\\]component[/\\]wrap[/\\]/,
]
: [];
return {
base,
define: {
global: 'globalThis',
},
server: {
host: true,
port: 3000,
proxy: {
'/snp-api': {
target: env.VITE_SNP_API_TARGET || 'http://211.208.115.83:8041',
changeOrigin: true,
secure: false,
},
},
},
plugins: [
react(),
isBuild && !isLocalDev && ({
name: 'exclude-dev-folders',
resolveId(source: string) {
const normalizedSource = source.replace(/\\/g, '/');
for (const pattern of excludePatterns) {
if (pattern.test(normalizedSource)) {
return { id: 'virtual:empty-module', moduleSideEffects: false };
}
}
return null;
},
load(id: string) {
if (id === 'virtual:empty-module') {
return 'export default null;';
}
return null;
},
} satisfies Plugin),
].filter(Boolean),
resolve: {
alias: {
'@': '/src',
},
},
esbuild: isBuild && !isLocalDev
? {
drop: ['console', 'debugger'],
}
: {},
build: {
target: 'es2022',
outDir: 'dist',
cssCodeSplit: true,
rollupOptions: {
output: {
manualChunks: {
vendor: ['react', 'react-dom', 'react-router-dom'],
map: ['ol', 'ol-ext'],
state: ['zustand'],
},
},
},
},
};
});