如何将 sapper/svelte 站点部署到 Gitlab Pages?

How do I deploy a sapper/svelte site to Gitlab Pages?

我正在尝试使用 gitlab 页面来托管由 Sapper 和 Svelte 生成的静态站点。

我使用了入门文档中的 sapper 入门应用程序:

npx degit "sveltejs/sapper-template#rollup" my-app

我按照 gitlab 文档的指示添加了 .gitlab-ci.yml 文件:

# This file is a template, and might need editing before it works on your project.
image: node:latest

# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
  paths:
    - node_modules/

pages:
  stage: deploy
  script:
  - npm run export
  - mkdir public
  - mv __sapper__/export public
  artifacts:
    paths:
    - public
  only:
  - master

当管道运行时,它说它通过了,但即使经过一天的等待,我仍然收到 404 错误。

有人用 sapper 成功做到了吗?

您移动的是导出文件夹,而不是其内容。将您的移动命令更改为

mv __sapper__/export/* public/

这样你的配置就是

# This file is a template, and might need editing before it works on your project.
image: node:latest

# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
  paths:
    - node_modules/

pages:
  stage: deploy
  script:
  - npm run export
  - mkdir public
  - mv __sapper__/export/* public/
  artifacts:
    paths:
    - public
  only:
  - master