Blog
One Bun file as dev server, bundler and Tailwind CSS watcher
The development server is a single TypeScript file: it serves the repo, bundles entry points on request, spawns a Tailwind CSS watcher per stylesheet and renders the generated routes. No framework, no config directory.
Bun.serve handles requests, Bun.build bundles an entry point when the browser asks for it, and Bun.spawn keeps a Tailwind CSS CLI watching each stylesheet. Static files fall through to the public directory, generated routes render from the same templates the build uses, and anything else is the 404 page.
The whole thing is shorter than most framework configuration files, and every behaviour is a line of code you can read. When the port is busy it tries the next one.
All posts