Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Destroyerrrocket opened this issue Dec 29, 2024 · 2 comments
Labels
bug Something isn't working cli Related to the dioxus-cli program manganis Related to the manganis crate

Comments

@Destroyerrrocket
Copy link

Destroyerrrocket commented Dec 29, 2024

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

@Destroyerrrocket
Copy link
Author

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.

Destroyerrrocket added a commit to Destroyerrrocket/dioxus that referenced this issue Dec 29, 2024
…here might be more than one destination for the same asset (DioxusLabs#3467)
@Destroyerrrocket
Copy link
Author

Proposed fix in #3469

@ealmloff ealmloff added bug Something isn't working cli Related to the dioxus-cli program manganis Related to the manganis crate labels Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli Related to the dioxus-cli program manganis Related to the manganis crate
Projects
None yet
Development

No branches or pull requests

2 participants