-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnitro.config.ts
52 lines (48 loc) · 1.24 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
import { Nitro, RollupConfig } from "nitropack/types";
import { handlersOpenApiMeta } from "./src/nitro-extensions/rollup/plugins/handlers-openapi-meta";
import type { Plugin } from "rollup";
//https://nitro.unjs.io/config
export default defineNitroConfig({
srcDir: "src/backend",
output: {
dir: "dist/backend",
},
experimental: {
openAPI: true,
database: true,
asyncContext: true,
},
openAPI: {
production: "runtime",
meta: {
title: "nitro-sample",
description: "nitro sample backend api",
version: "1.0",
},
},
database: {
default: {
connector: "sqlite",
options: {
name: "testdb",
},
},
},
hooks: {
"rollup:before": (nitro: Nitro, config: RollupConfig) => {
const rollupPlugins = config.plugins as Plugin[];
const handlersMetaIndex = rollupPlugins.findIndex(
(item) => item.name == "nitro:handlers-meta"
);
if (handlersMetaIndex !== -1) {
rollupPlugins.splice(handlersMetaIndex, 1); //移除 handlers-meta插件
}
rollupPlugins.push(handlersOpenApiMeta());
console.log(
"nitro rollup plugins",
rollupPlugins.map((p) => p.name)
);
},
},
compatibilityDate: "2024-08-27",
});