【问题标题】:How do I deploy a sapper/svelte site to Gitlab Pages?如何将 sapper/svelte 站点部署到 Gitlab Pages?
【发布时间】:2020-06-06 12:28:56
【问题描述】:

我正在尝试使用 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 错误。

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

【问题讨论】:

    标签: gitlab gitlab-ci gitlab-ci-runner svelte sapper


    【解决方案1】:

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

    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
    

    【讨论】:

    • 谢谢!那是缺失的部分。我还需要在“npm run export”脚本之前添加“npm install”。管道工作后,css 和 js 路径不是相对的。但是,这是一个单独的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-17
    • 1970-01-01
    • 2015-10-31
    • 1970-01-01
    • 1970-01-01
    • 2020-09-17
    相关资源
    最近更新 更多