Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
318 stars 53 forks source link

NextJs v14.2.2 missing styles with static export #1465

Closed Tasin5541 closed 1 month ago

Tasin5541 commented 1 month ago

Describe the bug

We have a NextJs v14.2.2 app with pages router. We are using static export (output: 'export') to deploy the app on static web app. However, after deploying, it seems all the styles are missing.

All styles are available if I run the output directory with npx serve@latest out locally.

Azure Pipelines YAML

name: Azure Static Web Apps CI/CD

pr:
  branches:
    include:
      - main
trigger:
  branches:
    include:
      - main

jobs:
  - job: clean_workspace
    workspace:
      clean: all

  - job: build_and_deploy_job
    displayName: Build and Deploy Job
    condition: or(eq(variables['Build.Reason'], 'Manual'),or(eq(variables['Build.Reason'], 'PullRequest'),eq(variables['Build.Reason'], 'IndividualCI')))
    pool:
      vmImage: ubuntu-latest
    variables:
      - group: Azure-Static-Web-Apps-brave-rock-024de2910-variable-group
    steps:
      - checkout: self
        submodules: true
      - task: AzureStaticWebApp@0
        inputs:
          azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN_BRAVE_ROCK_024DE2910)
          ###### 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: "/" # App source code path
          api_location: "api" # Api source code path - optional
          output_location: "out" # Built app content directory - optional
          is_static_export: true # false SSR - true SSG
        env: # Add environment variables here
          STORYBLOK_TOKEN: $(STORYBLOK_TOKEN)
          OUTPUT_MODE: $(OUTPUT_MODE)
    ###### End of Repository/Build Configurations ######

Expected behavior All styles should be available.

Additional context staticwebapp.config.json:

{
  "trailingSlash": "never",
  "routes": [
    {
      "route": "/fonts*",
      "headers": {
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Methods": "GET"
      }
    }
  ]
}
Tasin5541 commented 1 month ago

Turns out the issue was with the tailwind.config.ts file. The content paths had Component with capital 'C' in it but the project is using component with small 'c'. vscode ignores the case while building app, which is why it works locally.