运行时包管理器打包器测试运行器代码检查格式化指南参考博客反馈

使用 Astro 和 Bun 构建应用

使用 bun create astro 初始化一个全新的 Astro 应用。create-astro 包会检测你是否正在使用 bunx,并使用 bun 安装依赖。

terminal
bun create astro
Text
 astro   Launch sequence initiated.

╭─────╮  Houston:
│ ◠ ◡ ◠  很高兴你加入我们。
╰─────╯

   dir   Where should we create your new project?
         ./fumbling-field

  tmpl   How would you like to start your new project?
         Use blog template

  deps   Install dependencies?
         Yes

   git   Initialize a new git repository?
         Yes

      ✔  Project initialized!
         ■ Template copied
         ■ Dependencies installed
         ■ Git initialized

  next   起飞确认。探索你的项目吧!

         Enter your project directory using cd ./fumbling-field
         Run `bun run dev` to start the dev server. q + ENTER to stop.
         Add frameworks like react or tailwind using astro add.

         遇到困难?加入我们 https://astro.build/chat

╭─────╮  Houston:
│ ◠ ◡ ◠  祝你好运,宇航员!🚀
╰─────╯

使用 bunx 启动开发服务器。

默认情况下,Bun 使用 Node.js 运行开发服务器。若要改用 Bun 运行时,请传递 --bun 标志。

terminal
bunx --bun astro dev
Text
 astro  v7.2.2 ready in 200 ms
┃ Local    http://localhost:4321/
┃ Network  use --host to expose

在浏览器中打开 http://localhost:4321 查看结果。编辑源文件时,Astro 会热重载应用。


查看 Astro 文档。