Files
leaudit-platform-frontend/vite.config.ts
T
2025-06-04 11:25:53 +08:00

48 lines
1.4 KiB
TypeScript

import { vitePlugin as remix } from "@remix-run/dev";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
declare module "@remix-run/node" {
interface Future {
v3_singleFetch: true;
}
}
export default defineConfig({
plugins: [
remix({
future: {
v3_fetcherPersist: true,
v3_relativeSplatPath: true,
v3_throwAbortReason: true,
v3_singleFetch: true,
v3_lazyRouteDiscovery: true,
},
}),
tsconfigPaths(),
],
define: {
// 在构建时为客户端代码提供 process.env.NODE_ENV 变量
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "development"),
},
server: {
host: '0.0.0.0',
port: 5173,
open: true,
allowedHosts: ['nas.7bm.co', 'localhost', '127.0.0.1'], // 允许的主机名列表1
cors: true,
// HMR配置
hmr: {
// 控制HMR更新时行为
overlay: false,
},
},
// 优化依赖预构建配置
optimizeDeps: {
// 防止依赖预构建时触发页面刷新导致路由中断
force: false,
// 预构建这些依赖,避免首次加载时出现重新构建
include: ['react-pdf', 'pdfjs-dist', 'dayjs', '@remix-run/node', 'react-dom', 'axios', 'dayjs/plugin/utc', 'react-router-dom', 'jszip', 'ahooks', 'antd', 'immer', '@ant-design/icons'],
},
});