// vite.config.js(正确的 CommonJS 配置) const { defineConfig } = require("vite"); const uni = require("@dcloudio/vite-plugin-uni").default; // uni 插件需要 .default const AutoImport = require("unplugin-auto-import/vite"); // 旧版本 AutoImport 直接导出函数,无需 .default module.exports = defineConfig({ plugins: [ uni(), AutoImport({ include: [/\.js$/, /\.vue$/, /\.vue\?vue/], imports: [ "vue", { "@dcloudio/uni-app": [ "onLoad", "onShow", "onHide", "onUnload", "onReady", "onReachBottom", "onPageScroll", "uni.request", "uni.navigateTo", "uni.showToast", ], }, ], dts: "src/auto-imports.d.ts", }), ], server: { hmr: true, proxy: { "/api": { target: "http://192.168.1.42", changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, ""), secure: false, }, }, }, });