import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; import path from "path"; // https://vite.dev/config/ export default defineConfig({ plugins: [react()], css: { modules: { generateScopedName: "[name]__[local]___[hash:base64:5]", // 自定义类名生成规则 }, }, resolve: { alias: { "@": path.resolve(__dirname, "src"), }, // mainFields: ['module', 'jsnext:main', 'jsnext', 'main'], }, server: { host: true, port: 8080, open: true, cors: true, // vite 反向代理 proxy: { "/api": { target: "http://192.168.1.112:19801", changeOrigin: false, rewrite: (path) => path.replace(/^\/api/, ""), }, }, }, });