import { defineConfig } from 'vite'; import uni from '@dcloudio/vite-plugin-uni'; import path from 'path'; export default defineConfig({ plugins: [uni()], server: { host: '0.0.0.0', hmr: true, // 关闭热更新 proxy: { '/bdhealth/': { // 本地代理的地址 target: 'https://np.h03.p0551.com', changeOrigin: true, }, }, }, resolve: { alias: { // 指向 H5 版本 Vant 的正确路径 vant: path.resolve(__dirname, 'node_modules/vant'), }, // 增加 extensions 配置,帮助 Vite 识别 .vue 文件 extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'], }, // 关键:不设置任何output.format相关配置 // 让UniApp根据运行环境自动选择合适的格式(ES模块) // build: { // rollupOptions: { // external: ['@vant/weapp'], // output: { // globals: { // '@vant/weapp': 'vantWeapp' // } // } // } // } });