WEB/vite.config.ts

49 lines
1.4 KiB
TypeScript

import { fileURLToPath, URL } from 'node:url'
import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
// https://vite.dev/config/
export default defineConfig({
plugins: [
vue(),
vueDevTools(),
createSvgIconsPlugin({
// Specify the icon folder to be cached
iconDirs: [path.resolve(process.cwd(), 'src/icons/svg')],
// Specify symbolId format
symbolId: 'icon-[dir]-[name]',
}),
],
server: {
port: 5174,
host: '0.0.0.0',
// 允许所有主机访问开发服务器(如 test.wms.com、局域网 IP 等)
allowedHosts: true,
proxy: {
'/dev-api': {
target: 'http://localhost:9528', // Assuming Vue 2 backend is running here, user can change
changeOrigin: true,
rewrite: (path) => path.replace(/^\/dev-api/, '')
},
'/dl-api': {
target: 'https://dl.wms.gztbyc.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/dl-api/, '')
},
// 海康 SDK ISAPI 请求 → 本地代理 → NVR
'/ISAPI': {
target: 'http://localhost:17311',
changeOrigin: true
}
}
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
},
},
})