trunk
trunk copied to clipboard
trunk serve --bin/--example
Highly desired feature to include support for --bin (which would set data-bin on the index.html, unless already present) and --example.
I took a brief look into this. And I am not sure this is achievable.
I personally would also like to to just run:
trunk serve --example foo
However, … --bin is already used for dealing with web-workers. Having the data-bin attribute you mentioned triggers this. And having a web-worker in the mix, the examples I saw make actual use of that. You have two data-bin with <link rel="rust">. Overriding that might make things just complex.
Which brings me to --example, I am not sure how that would properly with the web-worker example mentioned above. --bin in combination with --example might not lead to a sane environment.
So fiddling with this, I fear we would be breaking some things that work quite well at the moment.
On the other hand, back the --example case, I noticed that most projects anyway have a full cargo project for examples. So why not improve the situation of starting trunk with a different base directory?
So that one can do:
trunk serve example/foo
@ctron - Maybe we could prioritize workspaces over examples?
I believe it's an extremely common case to have a monorepo with a frontend and backend crate in a workspace, but having an index.html in the example folder might be difficult to make sense of since there's no standard way to handle this.
For example, trunk serve -p frontend could just be a syntax sugar for (essentially) cd frontend && trunk serve
Maybe … however, so far (due to the way cargo works) we always ended up having the UI excluded from the main workspace. Still keeping things in the same repository.
Still, I do see the benefit of having -p foo for even more reasons. My hope would also be that this should be easier to implement, without breaking existing behavior.