Skip to content

The design language that makes your AI harness better at design.

JavaScript

Refactor to use Bun's HTML static site bundler

Paul Bakaus4cb80550407f
diff --git a/.gitignore b/.gitignore
index fc60dd010..b36047651 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,8 +3,7 @@ node_modules/
# Generated files
dist/*.zip
-public/css/styles.css
-public/dist/
+build/
# Build artifacts
*.log
diff --git a/public/index.html b/public/index.html
index 20fd6e4d4..e08f97d76 100644
--- a/public/index.html
+++ b/public/index.html
@@ -7,7 +7,7 @@
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;0,700;1,300;1,400&family=Instrument+Sans:wght@400;500;600;700&family=Inter:wght@400;500;600&family=Space+Grotesk:wght@400;500;600&display=swap" rel="stylesheet">
- <link rel="stylesheet" href="./css/styles.css">
+ <link rel="stylesheet" href="tailwindcss">
</head>
<body class="min-h-screen overflow-x-hidden leading-relaxed">
@@ -314,6 +314,6 @@
</div>
</footer>
- <script type="module" src="./dist/app.bundle.js"></script>
+ <script type="module" src="./app.js"></script>
</body>
</html>
diff --git a/scripts/build.js b/scripts/build.js
index dd14f73f2..1c966c587 100644
--- a/scripts/build.js
+++ b/scripts/build.js
@@ -48,64 +48,47 @@ const ROOT_DIR = path.resolve(__dirname, '..');
const DIST_DIR = path.join(ROOT_DIR, 'dist');
/**
- * Build Tailwind CSS for production
+ * Build static site using Bun's HTML bundler
+ * Automatically bundles JS, CSS (with Tailwind), and assets
*/
-function buildTailwindCSS() {
- const inputFile = path.join(ROOT_DIR, 'public', 'css', 'main.css');
- const outputFile = path.join(ROOT_DIR, 'public', 'css', 'styles.css');
+async function buildStaticSite() {
+ const entrypoint = path.join(ROOT_DIR, 'public', 'index.html');
+ const outdir = path.join(ROOT_DIR, 'build');
- console.log('🎨 Building Tailwind CSS...');
- try {
- execSync(`bunx @tailwindcss/cli -i "${inputFile}" -o "${outputFile}" --minify`, {
- cwd: ROOT_DIR,
- stdio: 'inherit'
- });
- console.log('βœ“ Tailwind CSS compiled to public/css/styles.css\n');
- } catch (error) {
- console.error('Failed to build Tailwind CSS:', error.message);
- process.exit(1);
- }
-}
-
-/**
- * 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...');
+ console.log('🌐 Building static site with Bun...');
try {
const result = await Bun.build({
entrypoints: [entrypoint],
outdir: outdir,
- target: 'browser',
- format: 'esm',
minify: true,
sourcemap: 'linked',
- naming: '[name].bundle.[ext]',
+ // Tailwind is handled automatically via bun-plugin-tailwind
+ // when using <link rel="stylesheet" href="tailwindcss" />
});
if (!result.success) {
- console.error('Bundle failed:');
+ console.error('Build 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`);
- }
+ // Calculate total size
+ const totalSize = result.outputs.reduce((sum, o) => sum + o.size, 0);
+ const jsFiles = result.outputs.filter(o => o.path.endsWith('.js'));
+ const cssFiles = result.outputs.filter(o => o.path.endsWith('.css'));
+
+ console.log(`βœ“ Static site built to ./build/`);
+ console.log(` HTML: 1 file`);
+ console.log(` JS: ${jsFiles.length} file(s) (${(jsFiles.reduce((s, f) => s + f.size, 0) / 1024).toFixed(1)} KB)`);
+ console.log(` CSS: ${cssFiles.length} file(s) (${(cssFiles.reduce((s, f) => s + f.size, 0) / 1024).toFixed(1)} KB)`);
+ console.log(` Total: ${(totalSize / 1024).toFixed(1)} KB\n`);
return result;
} catch (error) {
- console.error('Failed to bundle frontend JS:', error.message);
+ console.error('Failed to build static site:', error.message);
process.exit(1);
}
}
@@ -116,9 +99,8 @@ async function buildFrontendJS() {
async function build() {
console.log('πŸ”¨ Building cross-provider design plugins...\n');
- // Build frontend assets
- buildTailwindCSS();
- await buildFrontendJS();
+ // Build static site (HTML, JS, CSS with Tailwind)
+ await buildStaticSite();
// Read source files
const { commands, skills } = readSourceFiles(ROOT_DIR);
diff --git a/vercel.json b/vercel.json
index c2823844c..8d5fa3148 100644
--- a/vercel.json
+++ b/vercel.json
@@ -1,6 +1,6 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"buildCommand": "bun run build",
- "outputDirectory": "public"
+ "outputDirectory": "build"
}