-
Notifications
You must be signed in to change notification settings - Fork 460
/
build.config.ts
71 lines (68 loc) · 1.66 KB
/
build.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
61
62
63
64
65
66
67
68
69
70
71
import { defineBuildConfig } from "unbuild";
import { resolve } from "pathe";
import { fileURLToPath } from "node:url";
import { normalize } from "pathe";
const srcDir = fileURLToPath(new URL("src", import.meta.url));
export const subpaths = [
"cli",
"config",
"core",
"kit",
"presets",
"rollup",
"types",
"meta",
];
export default defineBuildConfig({
declaration: true,
name: "nitro",
entries: [
// CLI
{ input: "src/cli/index.ts" },
// Config
{ input: "src/config/index.ts" },
// Core
{ input: "src/core/index.ts" },
// Runtime
{ input: "src/runtime/", outDir: "dist/runtime", format: "esm" },
// Kit
{ input: "src/kit/index.ts" },
// Meta
{ input: "src/meta/index.ts" },
// Presets
{ input: "src/presets/", outDir: "dist/presets", format: "esm" },
// Rollup
{ input: "src/rollup/index.ts" },
// Types
{ input: "src/types/index.ts" },
],
alias: {
nitropack: "nitropack",
"nitropack/meta": resolve(srcDir, "../meta.ts"),
"nitropack/runtime/meta": resolve(srcDir, "../runtime-meta.mjs"),
...Object.fromEntries(
subpaths.map((subpath) => [
`nitropack/${subpath}`,
resolve(srcDir, `${subpath}/index.ts`),
])
),
},
externals: [
"nitropack",
"nitropack/runtime/meta",
...subpaths.map((subpath) => `nitropack/${subpath}`),
"firebase-functions",
"@scalar/api-reference",
],
rollup: {
output: {
chunkFileNames(chunk) {
const id = normalize(chunk.moduleIds.at(-1));
if (id.includes("/src/cli/")) {
return "cli/[name].mjs";
}
return "_chunks/[name].mjs";
},
},
},
});