Elderjs / template

Elder.js template project. It is part template, part tutorial. Dive in!
https://elderjs.pages.dev/
MIT License
113 stars 33 forks source link

Difficulty deploying template to gitlab pages due to project name in the url #47

Closed Cyprias closed 3 years ago

Cyprias commented 3 years ago

I got GitLab to build the project using this config. .gitlab-ci.yml

image: node:latest

pages:
  script:
    - npm install
    - npm run build
  artifacts:
    paths:
    - public
  cache:
    paths:
      - node_modules  
  only:
  - master

Gitlab Pages deploys projects as http://username.gitlab.io/project-name/. When visiting https://cyprias.gitlab.io/elderjs-app/, the project's index.html shows up without any of the css and links point to http://cyprias.gitlab.io/xyz instead of http://cyprias.gitlab.io/elderjs-app/xyz.

When setting settings.prefix to elderjs-app, the http://cyprias.gitlab.io/elderjs-app/ link becomes a 404 error. Instead the webpage is accessible at https://cyprias.gitlab.io/elderjs-app/elderjs-app/. The index.html is shown but without the css again as the css points to https://cyprias.gitlab.io/elderjs-app/_elderjs/assets/svelte-9e1a324b.css when it's now at https://cyprias.gitlab.io/elderjs-app/elderjs-app/_elderjs/assets/svelte-9e1a324b.css.

Setting settings.origin to https://cyprias.gitlab.io or https://cyprias.gitlab.io/elderjs-app doesn't seem to have any effect, with or without prefix having the project's name in it or not.

Any assistance would be greatly appreciated.

nickreese commented 3 years ago

@Cyprias It sounds like you're basically asking to prefix the assets but not the output content. Hard to follow.

I haven't used Gitlab's hosting process but it sounds like it needs some nonconventional deploy settings. I know things work well with pages.dev, netlify, s3, etc. Sorry I can't be of more help.

Cyprias commented 3 years ago

I think that's accurate. The html needs to prefix assets/links to deal with GL adding the project's name to the url. So that /assets/blaw.js becomes /some_prefix/assets/blaw.js.

In GL's sapper example, it uses npm run export -- --basepath $CI_PROJECT_NAME to provide the project's name to sapper's export script. Is there a similar type of parameter that can be provided to elder's build script?