Skip to content

No background image with CI

When working locally with the local webserver using yarn dev, everything's OK. Once I deploy it on GitLab.com pages using yarn build, background images are missing.

Here is my .gitlab-ci.yml file:

# Use a Node.js image
image: node:lts

# Cache node_modules to speed up subsequent runs
cache:
  key:
    files:
      - yarn.lock
  paths:
    - node_modules/
  policy: pull-push

# This single job builds and deploys the app to GitLab Pages
pages:
  script:
    - echo "🚀 Starting build and deploy..."
    - yarn install --frozen-lockfile
    - yarn build
    # Move the built assets to the 'public' directory, which GitLab Pages requires
    - cp -a dist/. public
  artifacts:
    paths:
      # This is the folder GitLab Pages will serve
      - public
  rules:
    # Only run this job on the main branch
    - if: $CI_COMMIT_BRANCH == "main"