Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trunk serve is broken #99

Closed
NiklasEi opened this issue Jan 14, 2024 · 8 comments
Closed

trunk serve is broken #99

NiklasEi opened this issue Jan 14, 2024 · 8 comments

Comments

@NiklasEi
Copy link
Owner

NiklasEi commented Jan 14, 2024

The trunk configuration from #90 is a proper solution to issues with absolute URLs in web builds but broke trunk serve, which doesn't like paths starting with a dot. Overwriting the URL in the serve section of Trunk.toml doesn't work since Trunk will add a leading "/" to the path. This should get fixed with trunk-rs/trunk#674

Find a setup that doesn't require ugly sed commands like before #90 but works out of the box with trunk build and trunk serve.

@Plonq
Copy link

Plonq commented Feb 19, 2024

Changing the path from ./ to / in Trunk.toml fixes the issue for me (and assets still work - i.e. /assets/audio/flying.ogg). Am I missing something? (Probably)

@NiklasEi
Copy link
Owner Author

Using / instead of ./ will break asset loading in scenarios where the app is hosted at a path other than root. This is the case for itch.io for example.

@Plonq
Copy link

Plonq commented Feb 22, 2024

Could that not be fixed with <base href="/my-path" /> in the index? I realise that would be a manual step.

@NiklasEi
Copy link
Owner Author

That might work if you know the path, yes. In the case of itch you would first have to deploy a broken build to get the path (e.g. html/5082781/), manually fix the html file and then re-deploy. With this kind of solution, your build is only going to work on a single platform/path.
If you are OK with manual fixes, it's easier to make a search and replace to use ./ in my opinion.

@Plonq
Copy link

Plonq commented Feb 23, 2024

Fair enough, I've never deployed to Itch.io before.
IMO / is still a better default, with documentation RE: Itch.io deployment, rather than the other way round.
EDIT: unless there's a solution that fixes both of course!
But it's up to you!

@NiklasEi
Copy link
Owner Author

It seems Trunk has recently fixed this. Using version 0.19.0-alpha.3 (cargo install trunk --version 0.19.0-alpha.3) with the following Trunk.toml file:

[build]
public_url = "./"

The serve command works properly and trunk build will link assets with ./ 🥳
I guess this was fixed in trunk-rs/trunk#717

@NiklasEi
Copy link
Owner Author

I'll close this issue by updating the Trunk.toml file once a full Trunk release works.

@NiklasEi
Copy link
Owner Author

Resolved with Trunk 0.19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants