34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { defineConfig } from "vite";
|
||
import tsConfigPaths from "vite-tsconfig-paths";
|
||
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
|
||
import react from "@vitejs/plugin-react";
|
||
import tailwindcss from "@tailwindcss/vite";
|
||
import path from "node:path";
|
||
import { fileURLToPath } from "node:url";
|
||
|
||
// 兼容 Node/Bun 双运行时的项目根定位
|
||
const here = path.dirname(fileURLToPath(import.meta.url));
|
||
|
||
export default defineConfig({
|
||
server: { port: 3311 },
|
||
build: {
|
||
// Bun 内置模块(Bun.sql)不打包,生产用 bun 运行时启动 dist/server/server.js
|
||
rolldownOptions: { external: ["bun"] },
|
||
},
|
||
// 客户端环境用 stub 解析 "bun"(db 模块经 server fn 依赖链进入客户端图,
|
||
// 动态 import("bun") 只在服务端执行)
|
||
environments: {
|
||
client: {
|
||
resolve: {
|
||
alias: [{ find: /^bun$/, replacement: path.resolve(here, "src/stubs/bun-client.ts") }],
|
||
},
|
||
},
|
||
},
|
||
plugins: [
|
||
tsConfigPaths({ projects: ["./tsconfig.json"] }),
|
||
tailwindcss(),
|
||
tanstackStart(),
|
||
react(),
|
||
],
|
||
});
|