This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
发布你的 Web 应用
了解如何使用 EAS Hosting 部署你的 Web 应用。
如果你正在构建一个通用应用,可以使用 EAS Hosting 快速部署你的网页应用。这是一项用于部署使用 Expo Router 和 React 构建的网页应用的服务。
🌐 If you are building a universal app, you can quickly deploy your web app using EAS Hosting. It is a service for deploying web apps built with Expo Router and React.
1 要求
1 要求
expo.web.output在你项目的 app.json 中,确保
expo.web.output 属性是 static 或
server。
导出你的 Web 项目
🌐 Export your web project
要部署你的网页应用,你需要创建网页项目的静态构建版本。通过运行以下命令将网页项目导出到 dist 目录中:
🌐 To deploy your web app, you need to create a static build of your web project. Export your web project into a dist directory by running the following command:
- npx expo export --platform web每次在部署之前修改了你的网页应用时,记得重新运行此命令。
初始部署
🌐 Initial deployment
要发布你的网页应用,请运行以下 EAS CLI 命令:
🌐 To publish your web app, run the following EAS CLI command:
- eas deploy第一次运行此命令后,系统会提示你为项目选择一个预览子域名。此子域名是用于创建预览 URL 的前缀,并用于生产部署。例如,在 https://test-app--1234.expo.app 中,test-app 是预览子域名。
🌐 After running this command for the first time, you'll be prompted to select a preview subdomain for your project. This subdomain is a prefix used to create a preview URL and is used for production deployments. For example, in https://test-app--1234.expo.app, test-app is the preview subdomain.
部署完成后,EAS CLI 将输出预览 URL 以访问你部署的应用。
🌐 Once your deployment is complete, the EAS CLI will output a preview URL to access your deployed app.
生产部署
🌐 Production deployment
要创建生产部署,请运行以下 EAS CLI 命令:
🌐 To create a production deployment, run the following EAS CLI command:
- eas deploy --prod部署完成后,EAS CLI 将输出生产 URL 以访问你部署的应用。
🌐 Once your deployment is complete, the EAS CLI will output a production URL to access your deployed app.
自动部署
🌐 Deploy automatically
你可以使用 EAS Workflows 自动将你的应用部署到网页。首先,你需要 配置你的项目,在项目根目录下添加一个名为 .eas/workflows/deploy-web.yml 的文件,然后添加以下工作流配置:
🌐 You can automatically deploy your app to the web with EAS Workflows. First, you'll need to configure your project, add a file named .eas/workflows/deploy-web.yml at the root of your project, then add the following workflow configuration:
name: Deploy web on: push: branches: ['main'] jobs: deploy_web: name: Deploy web type: deploy params: prod: true
上述工作流程将在每次提交到项目的 main 分支时创建一个网页部署。你也可以使用以下 EAS CLI 命令手动运行此工作流程:
🌐 The workflow above will create a web deployment on every commit to your project's main branch. You can also run this workflow manually with the following EAS CLI command:
- eas workflow:run deploy-web.yml了解有关常见模式的更多信息,请参阅工作流程示例指南。
🌐 Learn more about common patterns with the workflows examples guide.
了解更多
🌐 Learn more
你可以了解更多关于设置 部署别名、使用 自定义域 或 部署 API 路由 的信息。
🌐 You can learn more about setting up deployment aliases, using a custom domain, or deploying an API Route.