Publish a Svelte Web App with GitLab Pages
- Create and clone a new GitLab repository.
- Download and extract the Svelte Starter Template into the repository.
- Since your URL will be at a subdirectory (
https://username.gitlab.io/repository-name), make the references to the JS and CSS files in your
public/index.htmlfile relative. In other words, remove the leading
- Create a
.gitlab-ci.ymlfile at the top-level of the repository, with the following contents:This says, when there’s a new commit on master (last line), use the
image: node:latest pages: stage: deploy script: - npm install - npm run build artifacts: paths: - public only: - master
node:latestdocker image to check-out the code and run
npm run buildcommands.
Your site will now be live - find the URL under GitLab
Pages. Check the
CI/CD status page of your GitLab repository to see the status of the build process if you ever have issues with that. Unlike GitHub, the site is not public by default. To make it publicly accessible, go into GitLab
Visibility, project features, permissions and set
Everyone. Your site is now available!
I periodically write about technology, maps, open data, and other software topics. To get updates about new posts: