You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure静态Web应用部署子文件夹中Vue.js项目时,错误部署全部源码而非dist文件夹的问题求助

Azure静态Web应用部署子文件夹中Vue.js项目时,错误部署全部源码而非dist文件夹的问题求助

大家好,我在部署Azure静态Web应用时碰到了个棘手的问题,想请各位帮忙看看。

我的Vue.js项目存放在仓库的一个子文件夹内,GitHub Actions的工作流运行显示是成功的,日志里也明确记录npm run build执行完成,并且生成了dist目录。可部署后的网站却不对劲——打开浏览器开发者工具,居然能看到完整的项目源码:src文件夹、原始的.vue文件,整个项目结构都暴露出来了,这显然不符合生产构建的预期。

以下是我工作流文件中build_and_deploy_job部分的完整配置:

name: Azure Static Web Apps CI/CD
on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
      - main
jobs:
  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: true
          lfs: false
      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_THANKFUL_STONE_0D016A710 }}
          repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
          action: "upload"
          ###### 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: "./BDOOPT_VUE/bdo-optimizer-temp" # App source code path
          api_location: "" # Api source code path - optional
          output_location: "dist" # Built app content directory - optional
          ###### End of Repository/Build Configurations ######
        env:
          VUE_APP_API_URL: ${{ secrets.VUE_APP_API_URL }}
  close_pull_request_job:
    if: github.event_name == 'pull_request' && github.event.action == 'closed'
    runs-on: ubuntu-latest
    name: Close Pull Request Job
    steps:
      - name: Close Pull Request
        id: closepullrequest
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_THANKFUL_STONE_0D016A710 }}
          action: "close"

我已经尝试过调整output_location的参数值,但都没解决问题:如果把它改成非dist的其他路径,就会直接报错说位置无效。有没有朋友遇到过类似的情况,或者能帮我找找问题出在哪?

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.07 07:59:36