-
Notifications
You must be signed in to change notification settings - Fork 416
/
nitro.config.ts
60 lines (57 loc) · 1.31 KB
/
nitro.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import process from "node:process"
import { join } from "node:path"
import viteNitro from "vite-plugin-with-nitro"
import { RollopGlob } from "./tools/rollup-glob"
import { projectDir } from "./shared/dir"
const nitroOption: Parameters<typeof viteNitro>[0] = {
experimental: {
database: true,
},
rollupConfig: {
plugins: [RollopGlob()],
},
sourceMap: false,
database: {
default: {
connector: "sqlite",
},
},
imports: {
dirs: ["server/utils", "shared"],
},
preset: "node-server",
alias: {
"@shared": join(projectDir, "shared"),
"#": join(projectDir, "server"),
},
}
if (process.env.VERCEL) {
nitroOption.preset = "vercel-edge"
// You can use other online database, do it yourself. For more info: https://db0.unjs.io/connectors
nitroOption.database = undefined
// nitroOption.vercel = {
// config: {
// cache: []
// },
// }
} else if (process.env.CF_PAGES) {
nitroOption.preset = "cloudflare-pages"
nitroOption.database = {
default: {
connector: "cloudflare-d1",
options: {
bindingName: "NEWSNOW_DB",
},
},
}
} else if (process.env.BUN) {
nitroOption.preset = "bun"
nitroOption.database = {
default: {
connector: "bun-sqlite",
},
}
}
export default function () {
return viteNitro(nitroOption)
}