import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import { resolve } from 'path' import { fileURLToPath, URL } from 'node:url' import Icons from 'unplugin-icons/vite' import IconsResolver from 'unplugin-icons/resolver' import Components from 'unplugin-vue-components/vite' export default defineConfig({ plugins: [ vue(), Icons({ autoInstall: true, compiler: 'vue3' }), Components({ resolvers: [ IconsResolver({ prefix: 'i', enabledCollections: ['tabler'] }), ], }), ], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } }, server: { host: '0.0.0.0', port: 3002, strictPort: true, open: false, cors: true, allowedHosts: ['code.jingrow.com'], proxy: { '/api/action': { target: process.env.VITE_JINGROW_SERVER_URL || 'http://192.168.2.58', changeOrigin: true, secure: false }, '/api/data': { target: process.env.VITE_BACKEND_SERVER_URL || 'http://localhost:9001', changeOrigin: true, secure: false }, '/jingrow': { target: process.env.VITE_BACKEND_SERVER_URL || 'http://localhost:9001', changeOrigin: true, secure: false } } }, build: { outDir: 'dist', assetsDir: 'assets' }, define: { // 确保环境变量在构建时可用 __APP_VERSION__: JSON.stringify(process.env.npm_package_version) } })