| 123456789101112131415161718192021222324252627282930313233343536 |
- // 开发代理与统一前缀保证 fetch、文件下载和 SSE 使用同一套鉴权路径。
- import { defineConfig, loadEnv } from "vite";
- import vue from "@vitejs/plugin-vue";
- export default defineConfig(({ mode }) => {
- const env = loadEnv(mode, process.cwd(), "");
- // 使用已有 ESM 发行文件,避免受限 Windows 环境的预打包进程向盘符根目录扫描。
- return {
- plugins: [vue()],
- resolve: {
- alias: [
- { find: /^dayjs$/, replacement: "dayjs/esm/index.js" },
- {
- find: /^dayjs\/plugin\/([^/.]+)(?:\.js)?$/,
- replacement: "dayjs/esm/plugin/$1/index.js",
- },
- {
- find: /^dayjs\/locale\/([^/.]+)(?:\.js)?$/,
- replacement: "dayjs/esm/locale/$1.js",
- },
- ],
- },
- optimizeDeps: { noDiscovery: true, include: [] },
- server: {
- port: Number(env.FRONTEND_PORT || 5173),
- strictPort: true,
- proxy: {
- "/api/v1": {
- target: env.BACKEND_URL || "http://127.0.0.1:8000",
- changeOrigin: true,
- },
- },
- },
- preview: { port: 4173 },
- build: { chunkSizeWarningLimit: 1200 },
- };
- });
|