// esbuild build for @hive/dashboard. Outputs: // // dist/app.js bundled ES module (entrypoint = src/app.js, // pulls in @hive/shared + marked) // dist/dashboard.css bundled stylesheet (entrypoint = src/dashboard.css, // @import "@hive/shared/base.css" + terminal.css // get inlined here) // dist/index.html copy of src/index.html (esbuild doesn't process // HTML; the script/link tags reference the bundled // siblings by name) // // Both Rust binaries serve `dist/` via tower_http::ServeDir. The output // must keep the same filenames the existing index.html references, so // downstream changes are mechanical. import { build } from 'esbuild'; import { mkdirSync, copyFileSync, rmSync } from 'node:fs'; import { dirname, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; const here = dirname(fileURLToPath(import.meta.url)); const src = (p) => resolve(here, 'src', p); const dist = (p) => resolve(here, 'dist', p); rmSync(dist(''), { recursive: true, force: true }); mkdirSync(dist(''), { recursive: true }); // Bundle the JS entry. ES-module output, browser target, no minify // (line-aligned source aids debugging; minification belongs in a later // follow-up once asset sizes warrant it). await build({ entryPoints: [src('app.js')], outfile: dist('app.js'), bundle: true, format: 'esm', platform: 'browser', target: ['es2022'], sourcemap: true, logLevel: 'info', }); // Bundle the CSS — esbuild resolves @import including the package // re-exports from @hive/shared. await build({ entryPoints: [src('dashboard.css')], outfile: dist('dashboard.css'), bundle: true, loader: { '.css': 'css' }, logLevel: 'info', }); copyFileSync(src('index.html'), dist('index.html')); console.log('dashboard build ok →', dist(''));