Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: auto-create required function files #92

Merged
merged 16 commits into from
Nov 21, 2022
Merged

feat: auto-create required function files #92

merged 16 commits into from
Nov 21, 2022

Conversation

geoffrich
Copy link
Owner

@geoffrich geoffrich commented Oct 29, 2022

This PR simplifies the setup needed to use the adapter.

  • if you do not have any custom Azure functions, you only need to configure your build with the proper API location and static file location. Previously, you had to create a /api/render folder with some custom files in it.
  • if you have custom Azure functions, you can set the apiDir option to instruct the adapter to output the SvelteKit render function into a directory with the rest of your functions

This is a breaking change, but migration should be straightforward for most. See below for a migration guide. For a full working setup, see the demo folder in this repo.

Fix for #70. Also implements #42.

Migration guide

If you do not have additional custom Azure functions in the /api directory (the majority of users):

  • delete the /api directory.
  • (optional) remove the /api/render entry from your .gitignore
  • update your build configuration (likely in /.github/workflows/azure-static-web-apps-*.yml) to use build/server for the api_location. The adapter now outputs the built function into the build directory.
          app_location: '/demo' # App source code path
 -        api_location: 'api' # Api source code path - optional
 +        api_location: 'build/server' # Api source code path - optional
          output_location: 'build/static' # Built app content directory - optional

If you do have additional custom Azure functions in the /api directory:

  • update your .gitignore to ignore the new SvelteKit function directory, api/sk_render. Previously, this was api/render
  • remove the existing api/render folder. This no longer needs to be present in the repo at build time.
  • pass the apiDir option to the adapter and set it to the location of the api directory. The adapter will output a folder named sk_render to this directory that contains the Azure function for rendering.
// svelte.config.js
import adapter from 'svelte-adapter-azure-swa';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	kit: {
		adapter: adapter({ apiDir: 'api' })
	}
};

export default config;

If you have questions about the migration, please open an issue on this repo.

@geoffrich geoffrich marked this pull request as ready for review November 21, 2022 00:48
@github-actions
Copy link
Contributor

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-desert-00b80111e-92.westus2.2.azurestaticapps.net

@geoffrich geoffrich merged commit c682164 into main Nov 21, 2022
@geoffrich geoffrich deleted the issue-70 branch November 21, 2022 00:53
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
2 participants