import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import { fileURLToPath, URL } from 'node:url' // https://vite.dev/config/ export default defineConfig({ plugins: [vue()], server: { host: '0.0.0.0', // 允许局域网访问(手机/其他设备调试) proxy: { '/api': { target: 'http://127.0.0.1:8700', // payH5 本地后端,默认 8700 changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, ''), }, }, allowedHosts: ["vip.dsx2020.com", "localhost", "127.0.0.1", "192.168.41.222"] }, preview: { host: '0.0.0.0', // pnpm preview 时也可局域网访问 }, resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), }, }, build: { target: 'es2020', minify: 'esbuild', rollupOptions: { output: { manualChunks: { 'vue-vendor': ['vue', 'vue-router'], 'vant': ['vant'], 'supabase': ['@supabase/supabase-js'], }, chunkFileNames: 'assets/[name]-[hash].js', assetFileNames: 'assets/[name]-[hash][extname]', }, }, chunkSizeWarningLimit: 600, }, })