newsnow/vite.config.ts

49 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-09-26 19:16:42 +08:00
import process from "node:process"
2024-09-29 20:57:24 +08:00
import { fileURLToPath } from "node:url"
2024-10-03 17:24:29 +08:00
import nitroCloudflareBindings from "nitro-cloudflare-dev"
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-09-26 11:30:21 +08:00
export default defineConfig({
resolve: {
mainFields: ["module"],
},
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
modules: [nitroCloudflareBindings],
experimental: {
database: true,
},
database: {
default: {
connector: "cloudflare-d1",
options: {
bindingName: "CACHE_DB",
},
},
},
devDatabase: {
default: {
connector: "sqlite",
},
},
2024-09-29 20:57:24 +08:00
alias: {
"@shared": fileURLToPath(new URL("shared", import.meta.url)),
2024-10-03 13:16:14 +08:00
"#": fileURLToPath(new URL("server", import.meta.url)),
2024-09-29 20:57:24 +08:00
},
2024-10-03 17:24:29 +08:00
preset: "cloudflare-pages",
2024-09-26 11:30:21 +08:00
}),
],
})