執行環境套件管理器打包器測試執行器程式碼檢查格式化指南參考部落格意見回饋

使用 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 文件。