48 lines
1.7 KiB
TypeScript
48 lines
1.7 KiB
TypeScript
|
|
import { fileURLToPath, URL } from 'node:url'
|
||
|
|
import react from '@vitejs/plugin-react'
|
||
|
|
import { defineConfig, loadEnv } from 'vite'
|
||
|
|
|
||
|
|
function chunkName(moduleId: string): string | undefined {
|
||
|
|
if (moduleId.includes('/node_modules/react/') || moduleId.includes('/node_modules/react-dom/')) return 'react'
|
||
|
|
if (moduleId.includes('/node_modules/@tanstack/react-query/')) return 'query'
|
||
|
|
if (moduleId.includes('/node_modules/@tanstack/react-table/') || moduleId.includes('/node_modules/@tanstack/react-virtual/')) return 'table'
|
||
|
|
if (moduleId.includes('/node_modules/lucide-react/') || moduleId.includes('/node_modules/cmdk/')) return 'ui'
|
||
|
|
return undefined
|
||
|
|
}
|
||
|
|
|
||
|
|
export default defineConfig(({ mode }) => {
|
||
|
|
const env = loadEnv(mode, process.cwd(), '')
|
||
|
|
const apiTarget = env.VITE_DEV_API_PROXY || 'http://127.0.0.1:8600'
|
||
|
|
const wsTarget = apiTarget.replace(/^https:/i, 'wss:').replace(/^http:/i, 'ws:')
|
||
|
|
|
||
|
|
return {
|
||
|
|
plugins: react(),
|
||
|
|
base: '/app-v2/',
|
||
|
|
resolve: {
|
||
|
|
alias: {
|
||
|
|
'@': fileURLToPath(new URL('src', import.meta.url)),
|
||
|
|
'~components': fileURLToPath(new URL('src/components', import.meta.url)),
|
||
|
|
'~features': fileURLToPath(new URL('src/features', import.meta.url)),
|
||
|
|
'~types': fileURLToPath(new URL('src/types', import.meta.url)),
|
||
|
|
},
|
||
|
|
},
|
||
|
|
build: {
|
||
|
|
outDir: fileURLToPath(new URL('../web/app-v2', import.meta.url)),
|
||
|
|
emptyOutDir: true,
|
||
|
|
sourcemap: false,
|
||
|
|
rollupOptions: {
|
||
|
|
output: {
|
||
|
|
manualChunks: chunkName,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
server: {
|
||
|
|
port: 3002,
|
||
|
|
proxy: {
|
||
|
|
'/api': { target: apiTarget, changeOrigin: true, secure: false },
|
||
|
|
'/ws': { target: wsTarget, ws: true, changeOrigin: true, secure: false },
|
||
|
|
},
|
||
|
|
},
|
||
|
|
}
|
||
|
|
})
|