feat: supporting run on bun

This commit is contained in:
Ou 2024-10-24 19:29:44 +08:00
parent 9ad3622526
commit 99b06e51cb
3 changed files with 1386 additions and 1409 deletions

2777
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@ import type { NewsItem } from "@shared/types"
export default defineSource(async () => { export default defineSource(async () => {
const baseURL = "https://www.gelonghui.com" const baseURL = "https://www.gelonghui.com"
const html: any = await $fetch("https://www.gelonghui.com/news") const html: any = await $fetch("https://www.gelonghui.com/news/")
const $ = cheerio.load(html) const $ = cheerio.load(html)
const $main = $(".article-content") const $main = $(".article-content")
const news: NewsItem[] = [] const news: NewsItem[] = []

View File

@ -11,9 +11,6 @@ import type { VitePWAOptions } from "vite-plugin-pwa"
import { VitePWA } from "vite-plugin-pwa" import { VitePWA } from "vite-plugin-pwa"
import { projectDir } from "./shared/dir" import { projectDir } from "./shared/dir"
const isCF = process.env.CF_PAGES
const isVercel = process.env.VERCEL
dotenv.config({ dotenv.config({
path: join(projectDir, ".env.server"), path: join(projectDir, ".env.server"),
}) })
@ -68,18 +65,18 @@ const nitroOption: Parameters<typeof nitro>[0] = {
connector: "sqlite", connector: "sqlite",
}, },
}, },
preset: "node-server",
alias: { alias: {
"@shared": join(projectDir, "shared"), "@shared": join(projectDir, "shared"),
"#": join(projectDir, "server"), "#": join(projectDir, "server"),
}, },
preset: "node-server",
} }
if (isVercel) { if (process.env.VERCEL) {
nitroOption.preset = "vercel-edge" nitroOption.preset = "vercel-edge"
// You can use other online database, do it yourself. For more info: https://db0.unjs.io/connectors // You can use other online database, do it yourself. For more info: https://db0.unjs.io/connectors
nitroOption.database = undefined nitroOption.database = undefined
} else if (isCF) { } else if (process.env.CF_PAGES) {
nitroOption.preset = "cloudflare-pages" nitroOption.preset = "cloudflare-pages"
nitroOption.database = { nitroOption.database = {
default: { default: {
@ -89,6 +86,13 @@ if (isVercel) {
}, },
}, },
} }
} else if (process.env.BUN) {
nitroOption.preset = "bun"
nitroOption.database = {
default: {
connector: "bun-sqlite",
},
}
} }
export default defineConfig({ export default defineConfig({