MCPcopy Create free account
hub / github.com/anomalyco/opencode / createEmbeddedWebUIBundle

Function createEmbeddedWebUIBundle

packages/opencode/script/build.ts:27–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25const skipEmbedWebUi = process.argv.includes("--skip-embed-web-ui")
26
27const createEmbeddedWebUIBundle = async () => {
28 console.log(`Building Web UI to embed in the binary`)
29 const appDir = path.join(import.meta.dirname, "../../app")
30 const dist = path.join(appDir, "dist")
31 await $`OPENCODE_CHANNEL=${Script.channel} bun run --cwd ${appDir} build`
32 const files = (await Array.fromAsync(new Bun.Glob("**/*").scan({ cwd: dist })))
33 .map((file) => file.replaceAll("\\", "/"))
34 .filter((file) => !file.endsWith(".map"))
35 .sort()
36 const imports = files.map((file, i) => {
37 const spec = path.relative(dir, path.join(dist, file)).replaceAll("\\", "/")
38 return `import file_${i} from ${JSON.stringify(spec.startsWith(".") ? spec : `./${spec}`)} with { type: "file" };`
39 })
40 const entries = files.map((file, i) => ` ${JSON.stringify(file)}: file_${i},`)
41 return [
42 `// Import all files as file_$i with type: "file"`,
43 ...imports,
44 `// Export with original mappings`,
45 `export default {`,
46 ...entries,
47 `}`,
48 ].join("\n")
49}
50
51const embeddedFileMap = skipEmbedWebUi ? null : await createEmbeddedWebUIBundle()
52

Callers 1

build.tsFile · 0.85

Calls 1

logMethod · 0.45

Tested by

no test coverage detected