diff --git a/package.json b/package.json index 121cf27..3382d5e 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,7 @@ "toes": "src/cli/index.ts" }, "scripts": { - "start": "bun run src/server/index.tsx", - "dev": "bun run --hot src/server/index.tsx", - "test": "bun test", + "build": "./scripts/build.sh", "cli:build": "bun run scripts/build.ts", "cli:build:all": "bun run scripts/build.ts --all", "cli:install": "bun cli:build && sudo cp dist/toes /usr/local/bin", diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..385efff --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -euo pipefail + +echo ">> Building client bundle" + +# Clean pub directory +rm -rf pub/client +mkdir -p pub/client + +# Bundle client code +bun build src/client/index.tsx \ + --outfile pub/client/index.js \ + --target browser \ + --minify + +echo ">> Client bundle created at pub/client/index.js" +ls -lh pub/client/index.js diff --git a/src/server/index.tsx b/src/server/index.tsx index c315e00..55c9c21 100644 --- a/src/server/index.tsx +++ b/src/server/index.tsx @@ -5,18 +5,6 @@ import { Hype } from '@because/hype' const app = new Hype({ layout: false }) -// Serve pre-bundled client in production -if (process.env.NODE_ENV === 'production') { - app.get('/client/index.js', async (c) => { - const file = Bun.file('./dist/client/index.js') - if (!(await file.exists())) { - console.error('⚠️ Bundled client not found. Run `bun run build` first.') - return c.text('Client bundle not found', 500) - } - return new Response(file, { headers: { 'Content-Type': 'text/javascript' } }) - }) -} - app.route('/api/apps', appsRouter) app.route('/api/sync', syncRouter)