feat: change preview api url #1584

Merged
konrad merged 1 commits from dpschen/frontend:feature/feat-change-preview-api-url into main 2022-02-23 12:05:06 +00:00
2 changed files with 4 additions and 2 deletions

View File

@ -123,7 +123,6 @@ steps:
- yarn serve:dist & npx wait-on http://localhost:4173
- yarn test:frontend --browser chrome --record
depends_on:
- dependencies
- build-prod
- name: deploy-preview
@ -137,6 +136,9 @@ steps:
GITEA_TOKEN:
from_secret: gitea_token
commands:
- cp -r dist dist-preview
# Override the default api url used for preview
- sed -i 's|localhost:3456|try.vikunja.io|g' dist-preview/index.html

Great idea! We should make sure this doesn't interfer with the tests since the same bundle is used for the tests as well.

Great idea! We should make sure this doesn't interfer with the tests since the same bundle is used for the tests as well.

Wouldn't that collide here: 27bba71d8a/.drone.yml (L122) ?

Wouldn't that collide here: https://kolaente.dev/vikunja/frontend/src/commit/27bba71d8a9be9860f59284a8639008cb7a2e1b2/.drone.yml#L122 ?

I think so yes. Because yarn serve:dist will only serve whatever is in the dist folder, and if that gets reloaded we'll probably use the wrong api for the tests.

An option would be to wait with the deploy step until the tests are done.

I think so yes. Because `yarn serve:dist` will only serve whatever is in the `dist` folder, and if that gets reloaded we'll probably use the wrong api for the tests. An option would be to wait with the deploy step until the tests are done.

I think linting is fine, since it's so fast (didn't check if we do that already).
If we wait for Cypress it will take a lot longer. I wouldn't like that.

I think linting is fine, since it's so fast (didn't check if we do that already). If we wait for Cypress it will take a lot longer. I wouldn't like that.

Then I think copying the dist folder, making the adjustments and then deploying that would be the way to go?

Then I think copying the dist folder, making the adjustments and then deploying that would be the way to go?

After thinking about it I think I'm not understanding what you mean, sry :D
What shall I adjust?

After thinking about it I think I'm not understanding what you mean, sry :D What shall I adjust?

Something like this:

cp -r dist dist-preview
sed -i 's|http://localhost:3456/api/v1|https://try.vikunja.io/api/v1|g' dist-preview/index.html

And then adjust the netlify deploy script to deploy dist-preview instead of dist.

Something like this: ``` cp -r dist dist-preview sed -i 's|http://localhost:3456/api/v1|https://try.vikunja.io/api/v1|g' dist-preview/index.html ``` And then adjust the netlify deploy script to deploy `dist-preview` instead of `dist`.

Adjusted! :check

Adjusted! :check

Does it work? Looks like the link is broken.

Does it work? Looks like the link is broken.

I think I know why. Doesn't netlify build it again?

And if not what else is the yarn build in the netlify.toml for?

I think I know why. Doesn't netlify build it again? And if not what else is the [`yarn build`](https://kolaente.dev/vikunja/frontend/src/commit/b0b314df1a720ca797afaf411515bd955d8074a1/netlify.toml#L2) in the netlify.toml for?

Usually netlify builds the site when pusing to the git repo - that's what the config parameter is required for. We're not really using that though.

Usually netlify builds the site when pusing to the git repo - that's what the config parameter is required for. We're not really using that though.

I removed it before – that didn't work. But now it also doesn't work with it :D

I removed it before – that didn't work. But now it also doesn't work with it :D
- shasum -a 384 -c ./scripts/deploy-preview-netlify.js.sha384
- node ./scripts/deploy-preview-netlify.js
depends_on:

View File

@ -1,6 +1,6 @@
[build]
command = "yarn build"
publish = "dist"
publish = "dist-preview"
[[redirects]]
from = "/*"