透過 App Hosting 使用單一存放區
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
使用單一存放區,您可以在單一目錄中整理及管理多個專案。本指南說明如何開始使用 App Hosting 部署以 Nx 為基礎的應用程式。
透過 Firebase 控制台部署 Monorepo
Firebase 控制台的圖形後端設定流程內建 Monorepo 支援功能。系統在「部署設定」下方提示輸入「根目錄」時,請指定要部署的應用程式在單一存放區中的路徑:

使用 Firebase CLI 部署 Monorepo
Firebase CLI 指令 apphosting:backends:create
叫用的後端設定流程內建 Monorepo 支援功能。進入這個流程並指定所選 GitHub 存放區後,系統會提示您指定應用程式的根目錄 (相對於存放區);在提示中,傳遞要在 Monorepo 中部署的應用程式路徑:
$ firebase apphosting:backends:create --project [project-name]
i === Import a GitHub repository
✔ Connected with GitHub successfully
? Which GitHub repo do you want to deploy? gh-username/nx-monorepo
? Specify your app's root directory relative to your repository path/to/app
舉例來說,假設 Nx 專案結構如下,且「target-app」是您要建構及部署的應用程式,則部署的資產如下:
.
├── lib
├── apps
│ └── target-app
│ ├── project.json
│ └── src
│ └── ...
├── nx.json
├── package-lock.json
└── package.json
相對於存放區的應用程式根目錄為 apps/target-app
。
排解單一存放區部署問題
- 如果未指定「根目錄」欄位,建構作業就會失敗,並顯示 App Hosting 無法在 Nx 單一存放區中找到目標專案的訊息。
- 如果是 Nx + Angular 應用程式,您必須使用 Angular 應用程式建構工具建構應用程式。Angular 應用程式建構工具指定於
project.json
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-20 (世界標準時間)。
[null,null,["上次更新時間:2025-08-20 (世界標準時間)。"],[],[],null,["\u003cbr /\u003e\n\nWith monorepos, you can organize and manage multiple projects in a single\ndirectory. This guide describes how to get started deploying Nx-based apps with\nApp Hosting.\n\nDeploy monorepos with the Firebase console\n\nMonorepo support is built into the graphical backend setup flow in the Firebase\nconsole. When prompted for a \"Root directory\" under \"Deployment settings,\"\nspecify the path to the application you want to deploy inside the monorepo:\n\nDeploy monorepos with the Firebase CLI\n\nMonorepo support is built into the backend setup flow invoked by the Firebase\nCLI command `apphosting:backends:create`. After you enter this flow and specify\nyour chosen GitHub repository, you are prompted to specify your app's root\ndirectory relative to your repository; at this prompt, pass the path to the\napplication you want to deploy inside the monorepo: \n\n $ firebase apphosting:backends:create --project [project-name]\n i === Import a GitHub repository\n ✔ Connected with GitHub successfully\n\n ? Which GitHub repo do you want to deploy? gh-username/nx-monorepo\n ? Specify your app's root directory relative to your repository path/to/app\n\nFor example, here are the assets that would be deployed given the following Nx\nproject structure and \"target-app\" as the application you want to build and\ndeploy: \n\n .\n ├── lib\n ├── apps\n │ └── target-app\n │ ├── project.json\n │ └── src\n │ └── ...\n ├── nx.json\n ├── package-lock.json\n └── package.json\n\nThe app's root directory relative to your repository is `apps/target-app`.\n\nTroubleshooting monorepo deployment\n\n- If you do not specify the \"root directory\" field, then the build will fail and display a message that App Hosting cannot find a project to target inside the Nx monorepo.\n- For Nx + Angular applications, you must use the [Angular application\n builder](https://angular.io/guide/esbuild) to build the application. The Angular application builder is specified in `project.json`"]]