-
Notifications
You must be signed in to change notification settings - Fork 358
Expand file tree
/
Copy pathbuild.config.ts
More file actions
63 lines (61 loc) · 1.72 KB
/
Copy pathbuild.config.ts
File metadata and controls
63 lines (61 loc) · 1.72 KB
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
import { defineBuildConfig } from "obuild/config";
import { parseSync } from "oxc-parser";
import MagicString from "magic-string";
const entries = ["deno", "bun", "cloudflare", "service-worker", "node", "generic"];
export default defineBuildConfig({
entries: [
{
type: "bundle",
input: [
...entries.map((entry) => `src/_entries/${entry}.ts`),
"./src/tracing.ts",
"./src/rules/index.ts",
"./src/rules/cache.ts",
"./src/rules/proxy.ts",
"./src/rules/compiler.ts",
],
},
],
hooks: {
rolldownOutput(config) {
config.codeSplitting = {};
config.chunkFileNames = (chunkInfo) => {
if (chunkInfo.name === "src") {
return "h3.mjs";
}
return "[name].mjs";
};
},
async end() {
const { exportSource } = await import("mdzilla");
await exportSource("./docs", "./dist/docs", {
title: "H3 Documentation",
filter: (e) => !e.entry.path.startsWith("/blog"),
});
},
rolldownConfig(config) {
config.experimental ??= {};
config.experimental.attachDebugInfo = "none";
if (!Array.isArray(config.plugins)) {
config.plugins = [];
}
config.plugins.push({
name: "remove-comments",
renderChunk(code) {
const parsed = parseSync("index.js", code);
if (parsed.comments.length === 0) {
return;
}
const ms = new MagicString(code);
for (const comment of parsed.comments) {
if (/^\s*[#@]/.test(comment.value)) {
continue;
}
ms.remove(comment.start, comment.end);
}
return ms.toString();
},
});
},
},
});