将 Turborepo Next.js 应用程序部署到 Azure 静态 Web 应用程序

Wes*_*key 7 azure next.js azure-static-web-app turborepo

我正在尝试使用 GitHub 操作和自定义生成步骤将 Turborepo monorepo 中的 Next.js 站点部署到 Azure 静态 Web 应用程序。Next.js 站点配置为使用standalone输出,但在其他方面遵循预设配置。部署作业失败并出现以下错误:

Failed to find a default file in the app artifacts folder (apps/web/.next). Valid default files: index.html,Index.html.
If your application contains purely static content, please verify that the variable 'app_location' in your workflow file points to the root of your application.
Run Code Online (Sandbox Code Playgroud)

构建和部署作业配置如下:

Failed to find a default file in the app artifacts folder (apps/web/.next). Valid default files: index.html,Index.html.
If your application contains purely static content, please verify that the variable 'app_location' in your workflow file points to the root of your application.
Run Code Online (Sandbox Code Playgroud)

将 Turborepo monorepo 中的 Next.js 应用程序部署到 Azure 静态 Web 应用程序需要哪些配置或附加步骤?我确认可以成功部署monorepo 上下文之外的相同应用程序,但这无需自定义构建步骤即可完成。

仓库: https: //github.com/westonsankey/turbo-demo

nom*_*oda 1

我发现app_location应该指向apps/web

\n

如果构建应用程序,您应该.next在以下目录结构中看到输出:

\n
.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 apps\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 web\n\xe2\x94\x82       \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 .next\n\xe2\x94\x82       \xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 standalone\n\xe2\x94\x82       \xe2\x94\x82       \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 apps\n\xe2\x94\x82       \xe2\x94\x82       \xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 web\n\xe2\x94\x82       \xe2\x94\x82       \xe2\x94\x82       \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 server.js\n\xe2\x94\x82       \xe2\x94\x82       \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 package.json\n\xe2\x94\x82       \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 package.json\n\xe2\x94\x82       \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 staticwebapp.config.json\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 .github\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 workflows\n\xe2\x94\x82       \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 azure-static-web-apps.yml\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 package.json\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 turbo.json\n
Run Code Online (Sandbox Code Playgroud)\n

的内容apps/web/.next/standalone/apps/web/必须移至apps/web/.next/standalone/

\n

尝试使用此构建配置:

\n
.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 apps\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 web\n\xe2\x94\x82       \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 .next\n\xe2\x94\x82       \xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 standalone\n\xe2\x94\x82       \xe2\x94\x82       \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 apps\n\xe2\x94\x82       \xe2\x94\x82       \xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 web\n\xe2\x94\x82       \xe2\x94\x82       \xe2\x94\x82       \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 server.js\n\xe2\x94\x82       \xe2\x94\x82       \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 package.json\n\xe2\x94\x82       \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 package.json\n\xe2\x94\x82       \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 staticwebapp.config.json\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 .github\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 workflows\n\xe2\x94\x82       \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 azure-static-web-apps.yml\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 package.json\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 turbo.json\n
Run Code Online (Sandbox Code Playgroud)\n

这是一个使用turborepo和pnpm工作空间的有用示例存储库(我不是作者):

\n

https://github.com/vivekjilla/pnpm-nextjs-sample/

\n