mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 03:09:14 +08:00
56 lines
1.2 KiB
TypeScript
56 lines
1.2 KiB
TypeScript
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
|
|
} 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)
|
|
}
|