-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathbuild.config.mjs
More file actions
59 lines (57 loc) · 1.38 KB
/
build.config.mjs
File metadata and controls
59 lines (57 loc) · 1.38 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
import { readFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { defineBuildConfig } from "obuild/config";
const agents = [
"bonzi",
"clippy",
"f1",
"genie",
"genius",
"links",
"merlin",
"peedy",
"rocky",
"rover",
];
export default defineBuildConfig({
entries: [
{
type: "bundle",
input: [
"./src/index.ts",
"./src/agents/index.ts",
...agents.map((agent) => `./src/agents/${agent}/index.ts`),
],
rolldown: {
plugins: [
{
name: "inline-png",
resolveId(source, importer) {
if (source.endsWith(".png") && importer) {
return resolve(dirname(importer), source);
}
},
load(id) {
if (id.endsWith(".png")) {
const base64 = readFileSync(id, "base64");
return `export default "data:image/png;base64,${base64}"`;
}
},
},
],
},
},
],
hooks: {
rolldownOutput(cfg) {
cfg.chunkFileNames = ({ facadeModuleId, moduleIds }) => {
// src/agents/[name]/*.*
const agentName = /src\/agents\/([^/]+)\//.exec(facadeModuleId || moduleIds[0])?.[1];
if (agentName) {
return `agents/${agentName}/[name].mjs`;
}
return "[name].mjs";
};
},
},
});