Skip to content

Commit 16469f8

Browse files
committed
fix ui build
1 parent 932750c commit 16469f8

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

script/build-ui

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,5 @@ fi
1313
echo "Building UI..."
1414
npm run build
1515

16-
# Move files to expected locations
17-
echo "Organizing output..."
18-
mkdir -p dist
19-
mv dist/src/apps/get-me/index.html dist/get-me.html 2>/dev/null || true
20-
mv dist/src/apps/issue-write/index.html dist/issue-write.html 2>/dev/null || true
21-
mv dist/src/apps/pr-write/index.html dist/pr-write.html 2>/dev/null || true
22-
rm -rf dist/src 2>/dev/null || true
23-
24-
# Copy to Go embed location
25-
echo "Copying to pkg/github/ui_dist/..."
26-
mkdir -p ../pkg/github/ui_dist
27-
cp dist/*.html ../pkg/github/ui_dist/
28-
2916
echo "UI build complete. Output:"
30-
ls -la dist/
17+
ls -la ../pkg/github/ui_dist/*.html

ui/vite.config.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from "vite";
1+
import { defineConfig, Plugin } from "vite";
22
import react from "@vitejs/plugin-react";
33
import { viteSingleFile } from "vite-plugin-singlefile";
44
import { resolve } from "path";
@@ -10,10 +10,30 @@ if (!app) {
1010
throw new Error("APP environment variable must be set");
1111
}
1212

13+
// Plugin to rename the output file and remove the nested directory structure
14+
function renameOutput(): Plugin {
15+
return {
16+
name: "rename-output",
17+
enforce: "post",
18+
generateBundle(_, bundle) {
19+
// Find the HTML file and rename it
20+
for (const fileName of Object.keys(bundle)) {
21+
if (fileName.endsWith("index.html")) {
22+
const chunk = bundle[fileName];
23+
chunk.fileName = `${app}.html`;
24+
delete bundle[fileName];
25+
bundle[`${app}.html`] = chunk;
26+
break;
27+
}
28+
}
29+
},
30+
};
31+
}
32+
1333
export default defineConfig({
14-
plugins: [react(), viteSingleFile()],
34+
plugins: [react(), viteSingleFile(), renameOutput()],
1535
build: {
16-
outDir: "dist",
36+
outDir: resolve(__dirname, "../pkg/github/ui_dist"),
1737
emptyOutDir: false,
1838
rollupOptions: {
1939
input: resolve(__dirname, `src/apps/${app}/index.html`),

0 commit comments

Comments
 (0)