DioxusLabs/dioxus

Regression: dioxus-cli fails to create multiple processed copies of a same image with different options

Opened this issue · 2 comments

If you use two asset! macros, like:

use manganis::*;
pub struct BlogEntry {
    pub image_file_thumbnail: Asset,
    pub image_file_blog: Asset,
}

const BLOG: BlogEntry = BlogEntry {
    image_file_thumbnail: manganis::asset!(
        "./top.jpg",
        ImageAssetOptions::new()
            .with_size(ImageSize::Manual {
                width: 384,
                height: 384
            })
            .with_avif()
    ),
    image_file_blog: manganis::asset!(
        "./top.jpg",
        ImageAssetOptions::new().with_avif()
    ),
};

dioxus cli will generate, inconsistently, either one of the two images.

Steps To Reproduce
Create a trivial project with the code above with a jpg
compile by dx build --trace --verbose
Observe that a single image appears in target/dx//debug/web/public/<assets_folder>

Expected behavior
One file for each configuration, instead of a single one.

My guess as to why this is happening is that the AssetManifest at packages/cli-opt/src/lib.rs is mistakenly a hashmap over the absolute path of the original source of asset. This is wrong as this will mistakenly merge these resources. I think this would be easily fixed by changing this to a vector, or, alternatively, hash over the output directories as those are already made unique by mangaris.

Please do also note that in the past this used to work

Environment:

  • Dioxus version: 0.6.1
  • Rust version: 1.82.0
  • OS info: Arch Linux
  • App platform: web

Questionnaire
I would like to fix and I think I have a solution

While I can take a look at fixing this, I'd like some input on what/why this behavior was changed and overall whether my initial guess of the issue is in the right direction.

Proposed fix in #3469