Azure静态Web Apps部署报错:staticwebapp.config.json未找到
解决Azure静态Web应用部署时找不到staticwebapp.config.json的问题
问题核心原因
- 拼写错误:GitHub Actions配置中
config_file_location写成了/asstets,正确拼写应为assets;但这不是根本问题——源码中assets文件夹实际位于src目录下,根目录不存在/assets路径。 - 路径指向错误:
config_file_location的路径是相对于app_location(仓库根目录)的源码路径,你的staticwebapp.config.json实际在src/assets下,而非根目录的assets下。
修复步骤
1. 修正GitHub Actions配置中的路径
将config_file_location改为源码中配置文件的实际路径,同时修正拼写:
config_file_location: "/src/assets"
2. 确认构建命令有效性
确保npm run build-prod命令能正常执行Angular构建,将src/assets下的文件复制到dist/myApp/assets目录(本地已验证,CI环境需保证命令权限和依赖正常)。
3. 可选简化方案
若无需将配置文件放在assets目录,可直接将staticwebapp.config.json移到仓库根目录,此时可删除config_file_location配置(默认会在根目录查找),或设置为"/"。
验证部署
修改后重新触发GitHub Actions部署,Azure将能正确找到配置文件,并将其包含到最终部署产物中。
内容的提问来源于stack exchange,提问作者TheLegend27
相关产品推荐
相关产品推荐

