-
Notifications
You must be signed in to change notification settings - Fork 315
Expand file tree
/
Copy pathbuild.config.mjs
More file actions
50 lines (47 loc) · 1.41 KB
/
build.config.mjs
File metadata and controls
50 lines (47 loc) · 1.41 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
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"],
},
],
hooks: {
rolldownOutput(config) {
config.codeSplitting = {};
config.chunkFileNames = "h3-[hash].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";
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();
},
});
},
},
});