Skip to content

Latest commit

 

History

History
58 lines (40 loc) · 1.54 KB

File metadata and controls

58 lines (40 loc) · 1.54 KB
author cjk7989
ms.author jikunchen
ms.service azure-static-web-apps
ms.topic include
ms.date 07/02/2024

Configure for deployment

  1. Add a staticwebapp.config.json file to your application code with the following contents:

    {
        "navigationFallback": {
            "rewrite": "/index.html"
        }
    }

    Defining a fallback route allows your site to server the index.html file for any requests made against the domain.

    Check this file into your source code control system (such as git) if you're using one.

  2. Install the Azure Static Web Apps (SWA) CLI in your project.

    npm install -D @azure/static-web-apps-cli

    The SWA CLI helps you develop and test your site locally before you deploy it to the cloud.

  3. Create a new file for your project and name it swa-cli.config.json.

    The swa-cli.config.json file describes how to build and deploy your site.

    Once this file is created, you can generate its contents using the npx swa init command.

    npx swa init --yes
  4. Build your application for distribution.

    npx swa build
  5. Use the SWA CLI to sign into Azure.

    npx swa login --resource-group swa-tutorial --app-name swa-demo-site

    Use the same resource group name and static web app name that you created in the previous section. As you attempt to log in, a browser opens to complete the process if necessary.