I am setting up build pipelines in Azure DevOps, but cannot get the NuxtJS 3 app to run when deploying via a Release Pipeline.
When deploying it straight from the DevOps Build Pipeline, it works. This isn’t ideal for us.
A new Build Pipeline was set up to create a build artifact, which works. Downloading the artifact and publishing it from swa
works as expected too.
The issue is when I use a Release Pipeline in DevOps, which has a Deploy Azure Static Web App (Preview)
task, it doesn’t work. In the developer tools’ network tab I can see a lot of 404 errors, all trying to access the _nuxt
folder.
The Release Pipeline’s step in YAML (it’s extracted to the zip
directory in previous step):
steps:
- task: AzureStaticWebApp@0
displayName: 'Publishing Website'
inputs:
workingDirectory: zip
app_location: .app/.output/public
output_location: .app/.output/public
api_location: .app/.output/server
config_file_location: .app
skip_app_build: true
is_static_export: false
verbose: true
azure_static_web_apps_api_token: 'mytoken'
deployment_environment: Dev
production_branch: development
.app/swa-cli.config.json:
{
"$schema": "https://aka.ms/azure/static-web-apps-cli/schema",
"configurations": {
".app": {
"appLocation": ".output/public",
"apiLocation": ".output/server",
"outputLocation": ".output/public",
"apiLanguage": "node",
"apiVersion": "18",
"appName": "test123",
"resourceGroup": "dev-resources"
}
}
}
I tried adding the empty .nojekyll
file out of desperation, but that didn’t make a difference either.
EDIT
Build Definition:
trigger:
- development
pool:
vmImage: ubuntu-latest
variables:
- group: dev-variable-group
- name: buildVersion
value: $(Date:yyyyMMdd).$(Rev:r)
- name: artifactName
value: 'ui-artifact'
stages:
- stage: Build
jobs:
- job: BuildJob
steps:
- script: echo "##vso[task.setvariable variable=buildVersion;]$(Build.BuildNumber)"
displayName: 'Set Build Version Variable'
- task: NodeTool@0
inputs:
versionSpec: '18.x'
displayName: 'Install Node.js'
- script: npm install -g pnpm
displayName: 'Install pnpm'
- script: |
pnpm i
pnpm build
displayName: 'npm install and build'
# Package the app into a zip file
- script: zip -r $(buildVersion).zip .app
displayName: 'Package app into ZIP'
# Publish the zip as an artifact of the build
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(buildVersion).zip'
artifactName: $(artifactName)
2
Answers
I managed to get it working by removing
Deployment Environment
,Production Environment
, and then also setting theOutput location
to an empty string (although I am not sure this makes any difference)Since the
AzureStaticWebApp@0
task is a preview rather than stable version currently, there could be some defects on it. It is still in development and improvement.It is not recommended to use the preview version task in your production processes and environment.
For your case, you can try by referencing the documentation "Deploy Nuxt 3 sites with universal rendering on Azure Static Web Apps".