Search code examples
gitlabgitlab-cigitlab-ci-runnersveltesapper

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


I am trying to use gitlab pages to host my static site generated by Sapper and Svelte.

I used the sapper starter app from the getting started docs:

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

I added the .gitlab-ci.yml file as gitlab docs instrcuted:

# 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

When the pipeline runs, it says it passes, but I still get a 404 error even after a day of waiting.

Has anyone successfully done this with sapper??


Solution

  • You're moving the export folder, rather than its contents. Change your move command to

    mv __sapper__/export/* public/

    so that your config would be

    # 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