| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import { defineConfig } from "vite";
- import react from "@vitejs/plugin-react";
- import path from "path";
- export default defineConfig(() => {
- // 加载环境变量
- return {
- plugins: [react()],
- base: '/spaces/', // ← 必须加这一行
- // 路径别名
- resolve: {
- alias: {
- "@": path.resolve(__dirname, "./src"),
- },
- },
- // 开发服务器配置
- server: {
- port: 3000,
- host: true, // 监听所有地址
- open: false, // 自动打开浏览器
- // 代理配置
- proxy: {
- // 代理所有 /sohoyw-som 开头的请求
- "/sohoyw-som": {
- target: "http://52.83.132.95:8080",
- changeOrigin: true,
- // configure: (proxy) => {
- // proxy.on("proxyReq", (proxyReq) => {
- // // 添加模拟登录的 Cookie
- // proxyReq.setHeader(
- // "Authorization",
- // "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiZXhwIjoxNzY0NTMxMjM3fQ.15IfYua8M_cSE4i3kT86fanqO3OTG39fl2EJYXSQ1z8"
- // );
- // });
- // },
- },
- },
- },
- // 构建配置
- build: {
- outDir: "dist",
- sourcemap: false,
- // 消除打包大小超过500kb警告
- chunkSizeWarningLimit: 2000,
- rollupOptions: {
- output: {
- // 分包策略
- manualChunks: {
- "react-vendor": ["react", "react-dom"],
- "contentful-vendor": [
- "@contentful/f36-components",
- "@contentful/f36-icons",
- "@contentful/f36-tokens",
- ],
- },
- },
- },
- },
- };
- });
|