diff --git a/.gitignore b/.gitignore index 6efec9922..fc60dd010 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ node_modules/ # Generated files dist/*.zip public/css/styles.css +public/dist/ # Build artifacts *.log diff --git a/public/index.html b/public/index.html index 3e5d14a51..20fd6e4d4 100644 --- a/public/index.html +++ b/public/index.html @@ -9,17 +9,7 @@ - - - + @@ -324,6 +314,6 @@ - + diff --git a/scripts/build.js b/scripts/build.js index b60650af0..dd14f73f2 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -67,14 +67,58 @@ function buildTailwindCSS() { } } +/** + * Build frontend JavaScript bundle using Bun's bundler + */ +async function buildFrontendJS() { + const entrypoint = path.join(ROOT_DIR, 'public', 'app.js'); + const outdir = path.join(ROOT_DIR, 'public', 'dist'); + + console.log('📦 Bundling frontend JavaScript...'); + + try { + const result = await Bun.build({ + entrypoints: [entrypoint], + outdir: outdir, + target: 'browser', + format: 'esm', + minify: true, + sourcemap: 'linked', + naming: '[name].bundle.[ext]', + }); + + if (!result.success) { + console.error('Bundle failed:'); + for (const log of result.logs) { + console.error(log); + } + process.exit(1); + } + + // Find the main bundle output + const mainBundle = result.outputs.find(o => o.kind === 'entry-point'); + if (mainBundle) { + const bundleName = path.basename(mainBundle.path); + const bundleSize = (mainBundle.size / 1024).toFixed(1); + console.log(`✓ Frontend JS bundled to public/dist/${bundleName} (${bundleSize} KB)\n`); + } + + return result; + } catch (error) { + console.error('Failed to bundle frontend JS:', error.message); + process.exit(1); + } +} + /** * Main build process */ async function build() { console.log('🔨 Building cross-provider design plugins...\n'); - // Build Tailwind CSS first + // Build frontend assets buildTailwindCSS(); + await buildFrontendJS(); // Read source files const { commands, skills } = readSourceFiles(ROOT_DIR);