首页 > 解决方案 > Gitlab 页面 CI/CD 管道正在通过,但生成的页面不加载资源

问题描述

这是.gitlab-ci.yml文件:

pages:
  stage: deploy
  script:
  - apt-get update
  - apt-get install -y nodejs npm  # install NPM in order to build the website
  - npm install
  - npm run build                  # build the website
  - mv dist public                 # move the built website to the public directory
  artifacts:
    paths:
    - public
  only:
  - master

管道通过,即作业pagespages:deploy正在通过。该网站也正确构建:当我下载工件时,所有资源都存在于public目录中。

但是,当我查看生成的网站时,index.html 正在加载,但所有资源都没有(404 代码)。

这是回购:https ://gitlab.com/Cl00e9ment/kingdom-blazon-generator

标签: continuous-integrationgitlabgitlab-ci

解决方案


GitLab 的页面只支持静态网页,不支持动态网页。这意味着您不能运行类似的服务器node.js,而只能生成 HTML 和其他静态文件。

你可以在这里读更多关于它的内容:

https://docs.gitlab.com/ee/user/project/pages/#overview


推荐阅读