trunk icon indicating copy to clipboard operation
trunk copied to clipboard

Feature request: Do not add a slash for `--public-url .`

Open neocturne opened this issue 2 years ago • 1 comments

This is the same issue as #165, which was closed as the original reporter did not want to pursue it any further.

It would be great if there was a way to make the generated page path-independent by not using any absolute paths (I'd even argue that this should be the default). As far as I can tell, this is currently not possible; the commands suggested in #165 do not work:

  • trunk build --public-url . generates the following:
<script type="module">import init from '/./index-aff7550d9c9c0030.js';init('/./index-aff7550d9c9c0030_bg.wasm');</script>
  • trunk build --public-url '' generates the following:
<script type="module">import init from '//index-aff7550d9c9c0030.js';init('//index-aff7550d9c9c0030_bg.wasm');</script>

I can make this work by editing the generated file manually to the following:

<script type="module">import init from './index-aff7550d9c9c0030.js';init('./index-aff7550d9c9c0030_bg.wasm');</script>

neocturne avatar Feb 16 '22 23:02 neocturne

If anyone has a workaround for this, that would be great — I'm planning on using sed or similar... Thanks in advance.

max-sixty avatar Apr 05 '22 21:04 max-sixty

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Oct 20 '23 00:10 github-actions[bot]

i would very much like this to not be closed. as it is, it seems impossible to cleanly serve multiple trunk apps from their own folders on a simple file-based web server, or deploy to a shared domain (unless you're willing to bake their paths into the build, which makes things much less flexible)

colons avatar Oct 24 '23 18:10 colons

+1 this makes it really annoying to deploy trunks app to github pages

j-brn avatar Oct 26 '23 01:10 j-brn

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Nov 26 '23 00:11 github-actions[bot]

please do not close this issue.

colons avatar Nov 26 '23 11:11 colons

As PR https://github.com/trunk-rs/trunk/pull/616 was merged, I assume this should be closed with the next release of trunk.

ctron avatar Dec 12 '23 10:12 ctron

I think that's released as part of trunk 0.18.0. If not: sorry, please re-open.

ctron avatar Dec 13 '23 10:12 ctron

i'm a bit confused about the specifics of how this has been addressed. why are you checking for './' specifically, and not '.' or empty strings? those are the two things i thought to try, much like the author of this issue, and neither of those are respected in this case. i guess you can't stop adding a leading / in most cases for compatibility reasons, but it seems actively hostile to override the user's stated intention to set the base url as simply '.'

colons avatar Dec 29 '23 21:12 colons

I am sure there's room for improvement. If you have a good way do deal with all of this, I would really appreciate if you could create a tracking issue with a proposal.

ctron avatar Jan 02 '24 11:01 ctron

i could do that if you really prefer, but it would just be a duplicate of this one. my request here is for trunk to not add a leading slash when . or the empty string are handed in as --public-url. this is precisely the proposal made in this issue's title and description, and #616 does not implement it

colons avatar Jan 02 '24 12:01 colons

(i also feel like i'm missing information here. i don't understand why trunk adds / at all, and i feel like . makes the most sense as a default public url. if i want a leading /, i'd type that. but changing this behaviour would be a pretty severe backwards incompatibility, and i think the changes proposed here are the best compromise for now; they are the things that people will try when they see that a / is being added)

colons avatar Jan 02 '24 14:01 colons

Right, I fully agree that it's a bit messy right now. But maybe working towards a breaking change for 0.19 makes sense? But for that it also might make sense to create a tracking issue, not carrying all the history of this issue.

ctron avatar Jan 08 '24 07:01 ctron

okay, thank you; if breaking changes are on the table, that changes things. i've opened #668

colons avatar Jan 08 '24 22:01 colons