首页 > 解决方案 > 如何将 sapper/svelte 站点部署到 Gitlab Pages?

问题描述

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

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

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

我将 .gitlab-ci.yml 文件添加为 gitlab 文档指示:

# 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 错误。

有人用工兵成功地做到了这一点吗?

标签: gitlabgitlab-cigitlab-ci-runnersveltesapper

解决方案


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

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

推荐阅读