我已经设置了一个Azure静态Web应用程序,我有一个Angular 13 Web应用程序,我想发布到它。因此,我将我的git提交推送到Azure DevOps,并且DevOps中的Azure管道(当我在Azure Portal中创建静态Web应用程序时自动创建)被触发。到目前为止一切顺利。然而,当管道尝试构建应用程序(NPM)时,它会给出一个错误。我知道,如果我强制构建,Web应用程序无论如何都可以工作,作为临时解决方案,这就是我想要做的。我一直在摆弄Azure Pipeline的YAML,试图添加--force标志,但一整天之后,我仍然无法让它工作。以下是Azure Pipeline的YAML:
name: Azure Static Web Apps CI/CD
pr:
branches:
include:
- master
trigger:
branches:
include:
- master
jobs:
- 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-purple-grass-0e645d303-variable-group
steps:
- checkout: self
submodules: true
- task: AzureStaticWebApp@0
inputs:
azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN_PURPLE_GRASS_0E645D303)
###### 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 source code path - optional
output_location: "" # Built app content directory - optional
###### End of Repository/Build Configurations ######
字符串
如果有人能指出我可以在哪里添加--force标志,我会非常感激!
- 谢谢-谢谢
2条答案
按热度按时间pbossiut1#
要添加**--forceflag,可以在字段中添加自定义NPM build命令:app_build_command和API_build_command**。
举例来说:
字符串
有关更多详细信息,您可以参考此文档:Build configuration for Azure Static Web Apps
xxslljrj2#
触发器:
pool:vmImage:ubuntu-latest
步骤:
输入:
app_build_command:node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build -c develop --build-optimizer
app_location:'/'
API_location:'API'
output_location:'dist'
env:
Azure_static_web_apps_API_token:$(部署令牌)
NPM_CONFIG_FORCE:真实
NPM_CONFIG_LEGACY_PEER_DEPS:真实