Bun

指南生態系統

使用 Remix 和 Bun 建立應用程式

目前 Remix 開發伺服器 (remix dev) 依賴於 Bun 尚未實作的 Node.js API。下列指南使用 Bun 初始化專案並安裝相依性,但它使用 Node.js 來執行開發伺服器。

使用 create-remix 初始化 Remix 應用程式。

bun create remix

 remix   v1.19.3 💿 Let's build a better website...

   dir   Where should we create your new project?
         ./my-app

      ◼  Using basic template See https://remix.dev.org.tw/docs/en/main/guides/templates#templates for more
      ✔  Template copied

   git   Initialize a new git repository?
         Yes

  deps   Install dependencies with bun?
         Yes

      ✔  Dependencies installed

      ✔  Git initialized

  done   That's it!

         Enter your project directory using cd ./my-app
         Check out README.md for development and deploy instructions.

若要啟動開發伺服器,請從專案根目錄執行 bun run dev。這將使用 remix dev 指令啟動開發伺服器。請注意,將使用 Node.js 來執行開發伺服器。

cd my-app
bun run dev
  $ remix dev

  💿  remix dev

  info  building...
  info  built (263ms)
  Remix App Server started at https://127.0.0.1:3000 (http://172.20.0.143:3000)

開啟 https://127.0.0.1:3000 以檢視應用程式。您對 app/routes/_index.tsx 所做的任何變更都將在瀏覽器中熱重載。

在 localhost 上執行的 Remix 應用程式

若要建立並啟動應用程式,請從專案根目錄執行 bun run build 然後執行 bun run start

bun run build
 $ remix build
 info  building... (NODE_ENV=production)
 info  built (158ms)
bun start
 $ remix-serve ./build/index.js
 [remix-serve] https://127.0.0.1:3000 (http://192.168.86.237:3000)

閱讀 Remix 文件 以取得有關如何使用 Remix 建立應用程式的更多資訊。