import { defineConfig } from 'vite'; import uni from '@dcloudio/vite-plugin-uni'; import { nodePolyfills } from 'vite-plugin-node-polyfills'; // https://vitejs.dev/config/ export default defineConfig({ plugins: [ uni(), nodePolyfills({ // 启用需要的 polyfills include: ['buffer', 'crypto', 'stream', 'util'], globals: { Buffer: true, global: true, process: true, }, }), ], define: { global: 'globalThis', }, css: { preprocessorOptions: { scss: { // 静默废弃警告,特别是来自第三方依赖的警告 silenceDeprecations: ['legacy-js-api', 'import'], // 静默来自 node_modules 的警告 quietDeps: true, charset: false, }, }, }, // 开发服务器配置 server: { port: 5173, host: '0.0.0.0', open: true, // 代理配置解决CORS问题 proxy: { '/api': { target: 'http://localhost:8080', changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, ''), }, }, }, });