From 06d815628ee5abf6361dbe543cc06a2d0474de25 Mon Sep 17 00:00:00 2001 From: Abdullah Khan Date: Tue, 21 Mar 2023 15:07:01 +0100 Subject: [PATCH 1/3] Updated Readme.md for monorepo support --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/README.md b/README.md index a0869cb..fd0267d 100644 --- a/README.md +++ b/README.md @@ -187,3 +187,49 @@ This is currently only available when running in production on SWA. In addition, ### `context` All server requests to your SvelteKit app are handled by an Azure function. This property contains that Azure function's [request context](https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-node#context-object). + + +## Monorepo support + +If you're using [Turborepo](https://turbo.build/repo) or [Nx](https://nx.dev) to create a mono repo, please ensure you're using NPM as your package manager. PNPM doesn't install dependencies automatically and the build process fails. + +If your folder structure is like following: +``` +.github/ + ├── workflow-file1.yml + └── workflow-file2.yml +apps/ + ├── sveltekit-app + ├── nextjs-app + └── nuxtjs-app +packages/ + ├── ui + └── auth +package.json +turbo.json / nx.json +README.md + +``` + +In your Github workflow file for SvelteKit, update the jobs to: +``` +... + +steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: Build And Deploy + id: builddeploy + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ORANGE_GRASS_0778C6300 }} + repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) + action: "upload" + ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### + # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig + app_location: "./apps/sveltekit-app" # App source code path + api_location: "apps/sveltekit-app/build/server" # Api source code path - optional + output_location: "build/static" # Built app content directory - optional + ###### End of Repository/Build Configurations ###### +``` \ No newline at end of file From 42082ded16184bd418852457aa634a36ba4ed6e0 Mon Sep 17 00:00:00 2001 From: Abdullah Khan Date: Thu, 23 Mar 2023 18:16:25 +0100 Subject: [PATCH 2/3] Ran prettier format to fix styling issues in readme.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fd0267d..74effc4 100644 --- a/README.md +++ b/README.md @@ -188,12 +188,12 @@ This is currently only available when running in production on SWA. In addition, All server requests to your SvelteKit app are handled by an Azure function. This property contains that Azure function's [request context](https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-node#context-object). - ## Monorepo support -If you're using [Turborepo](https://turbo.build/repo) or [Nx](https://nx.dev) to create a mono repo, please ensure you're using NPM as your package manager. PNPM doesn't install dependencies automatically and the build process fails. +If you're using [Turborepo](https://turbo.build/repo) or [Nx](https://nx.dev) to create a mono repo, please ensure you're using NPM as your package manager. PNPM doesn't install dependencies automatically and the build process fails. + +If your folder structure is like following: -If your folder structure is like following: ``` .github/ ├── workflow-file1.yml @@ -212,6 +212,7 @@ README.md ``` In your Github workflow file for SvelteKit, update the jobs to: + ``` ... @@ -232,4 +233,4 @@ steps: api_location: "apps/sveltekit-app/build/server" # Api source code path - optional output_location: "build/static" # Built app content directory - optional ###### End of Repository/Build Configurations ###### -``` \ No newline at end of file +``` From dfad0b7e0c32ab981df69bb91b69a30e2dfb4f36 Mon Sep 17 00:00:00 2001 From: Geoff Rich <4992896+geoffrich@users.noreply.github.com> Date: Thu, 23 Mar 2023 12:02:55 -0700 Subject: [PATCH 3/3] Tweak README - don't mention specific monorepo tools - remove extraneous files - link pnpm issue - reword some things --- README.md | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 74effc4..9d68601 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ When deploying to Azure, you will need to properly [configure your build](https: If you use a custom API directory (see [below](#apiDir)), your `api_location` will be the same as the value you pass to `apiDir`. -If your `app_location` is not the repository root `./` but `./my_app_location`, then you also need to change the `api_location` to `my_app_location/build/server` (but not the `output_location`). +If your `app_location` is in a subfolder (e.g. `./my_app_location`), then your `api_location` should include the path to that subfolder (e.g. `my_app_location/build/server`.) `output_location` should still be `build/static`. ## Running locally with the Azure SWA CLI @@ -190,32 +190,23 @@ All server requests to your SvelteKit app are handled by an Azure function. This ## Monorepo support -If you're using [Turborepo](https://turbo.build/repo) or [Nx](https://nx.dev) to create a mono repo, please ensure you're using NPM as your package manager. PNPM doesn't install dependencies automatically and the build process fails. +If you're deploying your app from a monorepo, here's what you need to know. -If your folder structure is like following: +The build currently fails if you use `pnpm` as a package manager. You can track [this issue](https://github.com/geoffrich/svelte-adapter-azure-swa/issues/135) for updates. For now, you can work around the issue by using `npm` instead. + +Also, since your SvelteKit app is in a subfolder of the monorepo, you will need to update your deployment workflow. + +For instance, if you have the following folder structure: ``` -.github/ - ├── workflow-file1.yml - └── workflow-file2.yml apps/ ├── sveltekit-app - ├── nextjs-app - └── nuxtjs-app -packages/ - ├── ui - └── auth -package.json -turbo.json / nx.json -README.md - + └── other-app ``` -In your Github workflow file for SvelteKit, update the jobs to: - -``` -... +The `app_location` and `api_location` in your deployment configuration need to point to the `apps/sveltekit-app` subfolder. `output_location` should remain the same. Here's how that would look for an Azure SWA GitHub workflow: +```diff steps: - uses: actions/checkout@v2 with: @@ -229,8 +220,10 @@ steps: action: "upload" ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig - app_location: "./apps/sveltekit-app" # App source code path - api_location: "apps/sveltekit-app/build/server" # Api source code path - optional +- app_location: "./" # App source code path +- api_location: "build/server" # Api source code path - optional ++ app_location: "./apps/sveltekit-app" # App source code path ++ api_location: "apps/sveltekit-app/build/server" # Api source code path - optional output_location: "build/static" # Built app content directory - optional ###### End of Repository/Build Configurations ###### ```