Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Với monorepo, bạn có thể sắp xếp và quản lý nhiều dự án trong một thư mục duy nhất. Hướng dẫn này mô tả cách bắt đầu triển khai các ứng dụng dựa trên Nx bằng App Hosting.
Triển khai kho lưu trữ đơn bằng bảng điều khiển của Firebase
Tính năng hỗ trợ monorepo được tích hợp vào quy trình thiết lập phụ trợ đồ hoạ trong bảng điều khiển Firebase. Khi được nhắc nhập "Thư mục gốc" trong phần "Cài đặt triển khai", hãy chỉ định đường dẫn đến ứng dụng mà bạn muốn triển khai trong monorepo:
Triển khai kho lưu trữ đơn bằng Giao diện dòng lệnh (CLI) của Firebase
Tính năng hỗ trợ monorepo được tích hợp vào quy trình thiết lập phụ trợ do lệnh Firebase CLI apphosting:backends:create gọi. Sau khi nhập quy trình này và chỉ định kho lưu trữ GitHub mà bạn đã chọn, bạn sẽ được nhắc chỉ định thư mục gốc của ứng dụng so với kho lưu trữ; tại lời nhắc này, hãy truyền đường dẫn đến ứng dụng mà bạn muốn triển khai trong kho lưu trữ đơn:
$ firebaseapphosting: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
Ví dụ: sau đây là các thành phần sẽ được triển khai dựa trên cấu trúc dự án Nx và "target-app" là ứng dụng mà bạn muốn tạo và triển khai:
Thư mục gốc của ứng dụng so với kho lưu trữ của bạn là apps/target-app.
Khắc phục sự cố khi triển khai monorepo
Nếu bạn không chỉ định trường "thư mục gốc", thì quá trình tạo sẽ không thành công và hiển thị thông báo rằng App Hosting không tìm thấy dự án nào để nhắm đến trong kho lưu trữ đơn Nx.
Đối với các ứng dụng Nx + Angular, bạn phải sử dụng trình tạo ứng dụng Angular để tạo ứng dụng. Trình tạo ứng dụng Angular được chỉ định trong project.json
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[],[],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`"]]