Skip to content
Wassim Chegham edited this page Mar 8, 2022 · 4 revisions

What happens when we run the swa start <context> command?

What's the "context" and how does that differ from appLocation or outputLocation?

context determines how the emulator will serve the static content:

  • if context is a folder, then we will start the emulator and serve static content from that folder
  • if context is an HTTP address, then we will start the emulator and proxy req to the dev server

In both cases, we reconfigure appLocation and outputLocation to reflect that:

  • outputLocation= context
  • appLocation = cwd() (currently, we don't use appLocation if context is a dev server)
swa start <context>

When not provided, context maps to the pwd:

swa start ./

We use commander under the hood to implement commands. In our use case, context (a command) will take precedence over --app-location (an option or a flag).

How does it select the workflow file to use, especially if there's more than one?

The scans scans for azure-static-web-apps-**.yml files under cwd()/.github/workflows/, and picks the 1st one (non-deterministic!).

What does it use from the workflow?

app_build_command
api_build_command
app_location
output_location
api_location

These values are overridden by the user's config (CLI flags).

How does --build work?

We check for runtime type. We currently support Node.js and .NET:

  • For Node.js,
    • For app, we invoke npm install && <app_build_command>
    • For api we invoke npm install && <api_build_command>
  • For .NET,
    • We invoke dotnet build

Important: We don't build if context is a dev server.

How does the CLI determine which staticwebapp.config.json file to use?

We scan recursively the appLocation for staticwebapp.config.json (or the legacy file routes.json):

  • If we find both staticwebapp.config.json and routes.json, we pick staticwebapp.config.json.
  • If we find only routes.json, verify it's a valid SWA config file (some JS frameworks use the same filename for routing) then pick it.