GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: web ui bundle build on windows (#19337) · cbarber/opencode@ef7d1f7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/opencode/script
    • build.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/opencode/script/build.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/script/build.ts
+17-10Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,24 @@ const skipEmbedWebUi = process.argv.includes("--skip-embed-web-ui")
6868
const createEmbeddedWebUIBundle = async () => {
6969
console.log(`Building Web UI to embed in the binary`)
7070
const appDir = path.join(import.meta.dirname, "../../app")
71+
const dist = path.join(appDir, "dist")
7172
await $`bun run --cwd ${appDir} build`
72-
const allFiles = await Array.fromAsync(new Bun.Glob("**/*").scan({ cwd: path.join(appDir, "dist") }))
73-
const fileMap = `
74-
// Import all files as file_$i with type: "file"
75-
${allFiles.map((filePath, i) => `import file_${i} from "${path.join(appDir, "dist", filePath)}" with { type: "file" };`).join("\n")}
76-
// Export with original mappings
77-
export default {
78-
${allFiles.map((filePath, i) => `"${filePath}": file_${i},`).join("\n")}
79-
}
80-
`.trim()
81-
return fileMap
73+
const files = (await Array.fromAsync(new Bun.Glob("**/*").scan({ cwd: dist })))
74+
.map((file) => file.replaceAll("\\", "/"))
75+
.sort()
76+
const imports = files.map((file, i) => {
77+
const spec = path.relative(dir, path.join(dist, file)).replaceAll("\\", "/")
78+
return `import file_${i} from ${JSON.stringify(spec.startsWith(".") ? spec : `./${spec}`)} with { type: "file" };`
79+
})
80+
const entries = files.map((file, i) => ` ${JSON.stringify(file)}: file_${i},`)
81+
return [
82+
`// Import all files as file_$i with type: "file"`,
83+
...imports,
84+
`// Export with original mappings`,
85+
`export default {`,
86+
...entries,
87+
`}`,
88+
].join("\n")
8289
}
8390

8491
const embeddedFileMap = skipEmbedWebUi ? null : await createEmbeddedWebUIBundle()

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.