Hello from Bun!
Bun 1.0 less than an hour ago (at the time of publishing), and to celebrate this, I’ve migrated my blog’s build process to Bun! This details how I now publish my static Astro blog to Cloudflare Pages using Bun.
First, a warning…
Before attempting this yourself, be warned that I used some hacky workarounds to bypass some existing issues with Cloudflare Pages, and Bun. I don’t recommend this for important deployments yet.
Build an Astro site with Bun
Bun 1.0 supports Astro out the box. To start using it, make sure you have Bun installed and updated. Delete your existing package lockfile (
yarn.lock) and use Bun to install dependencies.
To build your site using Bun, set this as your build command.
Workaround for the
For those using
sharp, it currently has an issue when installed with Bun, but there are two workarounds you can try.
sharpas a trusted dependency in your
If the first workaround failed, prefix your
buildcommand with the following to install
bun --bun run astro build to test your site builds successfully.
Deploy to Cloudflare Pages
Cloudflare Pages has experimental support for Bun. I found a gist from a user in the Cloudflare Developers Discord which documents what you need to do to enable it.
In your Cloudflare dashboard, navigate to your project and add these two environment variables.
Commit and deploy!
If everything works locally, and your Cloudflare environment variables are set, you’re ready to deploy your site! My blog is still relatively small, and takes under a minute to build. However, now than Bun 1.0 is out, I’ll be looking at other repos to use as benchmarks, and test how far I can push Bun. If you want to stay up to date with all my planned Bun & Astro content, and all my other shenanigans, be sure to subscribe to my email list (or the RSS feed) and follow me on Twitter.