import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from '@vant/auto-import-resolver';
import { resolve } from 'path';

// https://vitejs.dev/config/
export default defineConfig({
	base: '/sgsafeh5/',
	plugins: [
		vue(),
		Components({
			resolvers: [VantResolver()],
		}),
	],
	resolve: {
		alias: {
			'@': resolve(__dirname, 'src'),
			'@/axios': resolve('./src/axios'),
			'@/stores': resolve('./src/stores'),
		},
	},
	server: {
		port: 4300,
		proxy: {
			'/api': {
				target: 'http://10.198.1.18:8003',
				changeOrigin: true,
				rewrite: (path) => path.replace(/^\/api/, '')
			},
			'/process': {
				target: 'http://10.198.1.18:8003',
				changeOrigin: true
			},
			// 添加新的代理规则用于DeepSeek API
			'/deepseek-api': {
				target: 'http://10.19.13.166',
				changeOrigin: true,
				rewrite: (path) => path.replace(/^\/deepseek-api/, '/deepseek')
			},
			'/map': {
				target: 'https://restapi.amap.com',
				changeOrigin: true,
				rewrite: (path) => path.replace(/^\/map/, '')
			},
		}
	},
});
