Skip to content

Commit 2272a37

Browse files
committed
feat(firebase): add web asset build pipeline for hosting
Add build:web script to copy web client files from src/web/client to dist/web. Update CI workflow to build web assets before deployment and configure firebase.json to serve from the build output directory.
1 parent b9889b8 commit 2272a37

4 files changed

Lines changed: 45 additions & 2 deletions

File tree

.github/workflows/firebase-hosting-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
14-
- run: bun i && bun run build
14+
- run: bun i && bun run build:web && bun run build
1515
- uses: FirebaseExtended/action-hosting-deploy@v0
1616
with:
1717
repoToken: ${{ secrets.GITHUB_TOKEN }}

firebase.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"hosting": {
3-
"public": "public",
3+
"public": "dist/web",
44
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
55
"rewrites": [
66
{

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"build": "bun build src/index.ts --outdir ./dist --target node --packages external --format esm",
4040
"build:bun": "bun build src/index.ts --outdir ./dist --target node --packages external --format esm",
4141
"build:plugins": "bun run -F @involvex/super-agent\\* build",
42+
"build:web": "bun run scripts/build-web.ts",
4243
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
4344
"compile": "bun run prebuild && bun build --compile src/index.ts --outfile ./dist/super-agent-cli.exe --config bunfig.toml",
4445
"dev": "bun run --watch src/index.ts",

scripts/build-web.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import * as fs from "fs-extra";
2+
import * as path from "path";
3+
4+
/**
5+
* Build script for preparing web assets for Firebase Hosting.
6+
* Copies files from src/web/client to dist/web for deployment.
7+
*/
8+
9+
async function buildWeb(): Promise<void> {
10+
const srcDir = path.join(process.cwd(), "src/web/client");
11+
const destDir = path.join(process.cwd(), "dist/web");
12+
13+
console.log("Building web assets for Firebase Hosting...");
14+
15+
// Ensure source directory exists
16+
if (!(await fs.pathExists(srcDir))) {
17+
console.error(`Source directory not found: ${srcDir}`);
18+
console.error("Please ensure src/web/client exists with web assets.");
19+
process.exit(1);
20+
}
21+
22+
// Ensure destination directory exists
23+
await fs.ensureDir(destDir);
24+
25+
// Copy web client files to dist/web
26+
const filesCopied = await fs.copy(srcDir, destDir, {
27+
filter: src => !src.includes("node_modules"),
28+
});
29+
30+
console.log("✅ Web assets prepared: dist/web");
31+
console.log(` Source: ${srcDir}`);
32+
console.log(` Destination: ${destDir}`);
33+
34+
// List what was copied
35+
const files = await fs.readdir(destDir);
36+
console.log(` Files: ${files.length} items copied`);
37+
}
38+
39+
buildWeb().catch(error => {
40+
console.error("Build failed:", error);
41+
process.exit(1);
42+
});

0 commit comments

Comments
 (0)