Skip to content

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

JavaScript

Add Bun bundler for frontend JavaScript

Paul Bakaus2fb61defca58
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 @@
<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">
- <!-- Import Maps for ES Module dependencies -->
- <script type="importmap">
- {
- "imports": {
- "lenis": "https://cdn.jsdelivr.net/npm/[email protected]/+esm",
- "motion": "https://cdn.jsdelivr.net/npm/[email protected]/+esm",
- "three": "https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js"
- }
- }
- </script>
-</head>
+ </head>
<body class="min-h-screen overflow-x-hidden leading-relaxed">
<!-- Skip to main content link for keyboard users -->
<a href="#main-content" class="skip-link">Skip to main content</a>
@@ -324,6 +314,6 @@
</div>
</footer>
- <script type="module" src="./app.js"></script>
+ <script type="module" src="./dist/app.bundle.js"></script>
</body>
</html>
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);