📎 Webclip
Custom Site Generation with Azure Static Web Apps
The post explains that Azure Static Web Apps can work with more than the default npm build flow. Because the service commits a GitHub Actions workflow into the repository, the workflow can be edited safely to add a custom build step and change the app path used for deployment.
Reading notes#
- Azure Static Web Apps generates and commits the GitHub Actions workflow when the project is created.
- The committed workflow can be edited, so a custom build step can be added.
- Oryx tries to infer the app type and run the matching build commands.
- If Oryx cannot determine the app type, it treats the project as already built or as a plain static site.
- The example starts with a failed build because the application root was set to
/while the static files were in/src. - The workflow includes a section marked as safe to edit, with
######comments showing the boundaries. - Changing
app_locationfrom/tosrcmakes the static deployment succeed. - The site is a simple event registration form with an empty event drop-down.
- A
services.csvfile in the repository could be parsed with JavaScript libraries, but the post chooses a static generation approach instead. - The added F# script reads the CSV, filters the services for the upcoming week, and writes modified HTML and other files to
/out. - The script uses AngleSharp, Deedle, and
dotnet fsi --langversion:preview. - After adding the generator, the workflow is updated again so
app_locationpoints toout. - The workflow also adds a .NET Core setup step and a generate step before deployment.
- The result is a deployed form with event options generated from the CSV data.
- The post says Azure Static Web Apps may not support every static site generator directly, but it can still be used with custom tweaks to the workflow.
