Restore asset_dir
Regression
The asset_dir field was removed in #4095 without a replacement. The asset macro works in most cases, but it doesn't work if you need to reference another asset inside an existing asset (#3325). We shouldn't remove it until we have a replacement for that use case
An option to not hash assets might be a better approach to this issue. Waiting to work on this until #3988 is merged to avoid conflicts
Doesn't the folder asset type exist for this reason? It should be possible to join a path against the folder to have assets reference each other?
Doesn't the folder asset type exist for this reason? It should be possible to join a path against the folder to have assets reference each other?
Only if you have access to the hashed asset folder name in your other asset. Eg. if I have a CSS file like this it isn't easy to swap all of the unhashed names for the final names of the hashed asset:
/* my_file.css */
.my-logo {
background-image: url('/assets/logo.png');
mask: ...
}
To fix the issue we need to either allow unhashed assets or find all nested asset references, which is impossible if we don't recognize the file format.
For css specifically, you can work around the issue by using relative links within a hashed asset folder, but I'm not sure that is true for every asset type. It depends on how the asset is interpreted by the program
@ealmloff did #4312 make it into 0.7.0-alpha.3?
@ronnybremer we are already using this on 0.7.0-alpha.3, so yes 👍🏽
The settings was a bit different than proposed here, I had to look that up. I'm on the go now. I'll post code when I'm back home.
Thank you!
@ronnybremer this is what we e.g. got for our app manifest.json etc. in main:
#[used]
static APP_MANIFEST: Asset = asset!(
"/assets/manifest.json",
AssetOptions::builder().with_hash_suffix(false)
);
#[used]
static APP_LOGO: Asset = asset!(
"/assets/app_logo_white.png",
AssetOptions::image().with_png().with_hash_suffix(false)
);
#[used]
static APP_WORKER_JS: Asset = asset!("/assets/sw.js", AssetOptions::js().with_hash_suffix(false));
@niclashoyer thats exactly what I tried, with one small difference:
#[used]
static _FONTS: Asset = asset!(
"/assets/fonts/webfonts/fa-solid-900.woff2",
AssetOptions::builder()
.with_hash_suffix(false)
.into_asset_options()
);
and dx will not export this font. In verbose mode I see it finds all other assets, but not the one declared above.
I will open a new issue, we have been hijacking this one :)