2024-09-26 19:16:42 +08:00
|
|
|
import process from "node:process"
|
2024-10-03 23:11:10 +08:00
|
|
|
import { join } from "node:path"
|
2024-09-26 11:30:21 +08:00
|
|
|
import { defineConfig } from "vite"
|
|
|
|
import react from "@vitejs/plugin-react-swc"
|
|
|
|
import nitro from "vite-plugin-with-nitro"
|
|
|
|
import { TanStackRouterVite } from "@tanstack/router-plugin/vite"
|
|
|
|
import tsconfigPath from "vite-tsconfig-paths"
|
2024-09-26 19:16:42 +08:00
|
|
|
import unocss from "unocss/vite"
|
2024-10-03 23:11:10 +08:00
|
|
|
import { projectDir } from "./shared/dir"
|
|
|
|
|
|
|
|
const isCF = process.env.CF_PAGES
|
2024-09-26 11:30:21 +08:00
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
plugins: [
|
|
|
|
TanStackRouterVite({
|
|
|
|
autoCodeSplitting: true,
|
|
|
|
}),
|
2024-09-26 19:16:42 +08:00
|
|
|
unocss(),
|
2024-09-26 11:30:21 +08:00
|
|
|
tsconfigPath(),
|
|
|
|
react(),
|
|
|
|
nitro({ ssr: false }, {
|
|
|
|
srcDir: "server",
|
2024-10-03 17:24:29 +08:00
|
|
|
experimental: {
|
|
|
|
database: true,
|
|
|
|
},
|
|
|
|
database: {
|
|
|
|
default: {
|
2024-10-11 20:50:09 +08:00
|
|
|
connector: isCF ? "cloudflare-d1" : "sqlite",
|
2024-10-03 17:24:29 +08:00
|
|
|
options: {
|
|
|
|
bindingName: "CACHE_DB",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-29 20:57:24 +08:00
|
|
|
alias: {
|
2024-10-03 23:11:10 +08:00
|
|
|
"@shared": join(projectDir, "shared"),
|
|
|
|
"#": join(projectDir, "server"),
|
2024-09-29 20:57:24 +08:00
|
|
|
},
|
2024-10-03 23:11:10 +08:00
|
|
|
preset: isCF ? "cloudflare-pages" : "node-server",
|
2024-09-26 11:30:21 +08:00
|
|
|
}),
|
|
|
|
],
|
|
|
|
})
|