我目前正在测试一个 Angular 应用程序/Java 微服务后端,并将前端部署在 Gitlab Pages 上。
到目前为止, gitlab-ci.yml 非常简单,因为我只是在测试架构:
cache:
paths:
- node_modules/
stages:
- staging
pages:
image: node:latest
stage: staging
script:
- npm install -g @angular/cli@11.0.1
- npm install
- ng build --prod
artifacts:
paths:
- public
我将 angular.json 更改为输出 public/ 而不是 dist/。该站点在地址https://myaccount.gitlab.io/repository-name上部署得很好,但只有 index.html 有效。
原因是,里面的所有 href 都有些错误:
<script src="runtime.0e49e2b53282f40c8925.js" defer></script>
<script src="polyfills.e6e62ba5ee83d54cee93.js" defer></script>
<script src="main.26f4db6ed1e6241cbf51.js" defer></script>
href 指向https://myaccount.gitlab.io/runtime.0e49e2b53282f40c8925.js而不是https://myaccount.gitlab.io/repository-name/runtime.0e49e2b53282f40c8925.js,所以我所有的裁判都会抛出 404 错误
有谁知道为什么会这样,以及如何解决?多谢 !