trunk
trunk copied to clipboard
serve-link-dir proposal
Let's say I have a very large media dir with videos, tons of images, etc. In fact, let's say it's in some huge shared network drive
Is there a way to tell trunk to serve files from there, without having to copy it all over into dist
on each build step?
If this isn't already supported out of the box, may I propose a serve-link-dir
asset type? e.g.
<link data-trunk rel="serve-link-dir" href="/shared/path/to/dir"/>
(with optional data-target-path
)
It would only work for serving, but in all senses, including watching and reloading on file change.
It would not copy anything out on build - for it to work on deployments, it's up to the application code to do the right thing, or add their own explicit copy step outside of trunk, e.g. something like:
fn media_url(s: &str) -> String {
let is_debug = match std::env::var("TRUNK_PROFILE") {
Ok(e) => e == "debug",
Err(_) => false
};
if is_debug {
// being served via trunk's serve-link-dir feature
format!("/media/{}", s)
} else {
// production build, only exists in a remote server somewhere
format!("https://cdn.example.com/{}", s)
}
}