collect-assets icon indicating copy to clipboard operation
collect-assets copied to clipboard

Manganis Fails To Provide Assets In Workspaces & Examples

Open DogeDark opened this issue 1 year ago • 1 comments
trafficstars

Problem

When using a workspace that uses Manganis, assets are not provided for binaries inside the workspace (such as example projects). It works normally when using the library outside of the workspace.

This also occurs in non-workspaces for project examples ran with cargo run --example {example}

Steps To Reproduce

  • Create a new cargo workspace with a Dioxus library and binary.
  • Inside the library, import a stylesheet using the mg! macro.
  • Inside the binary, add the library as a dependency.
  • Run the binary and check the <head> tag for stylesheet links.

It occurs for every asset, not just stylesheets. It's just the easiest to setup.

Expected behavior

Assets are provided correctly.

Environment:

  • Manganis version: 0.2.2
  • Rust version: 1.77.1
  • OS info: Windows 10
  • App platform: Web

DogeDark avatar Apr 06 '24 04:04 DogeDark

I am currently working on implementing support for manganis to trunk via manganis-cli-support, I noticed similar behaviour when writing an example.

From what I can tell, it's something to do with relative paths.

I did a bit digging around and saw the asset was found and hashed in both cases by manganis. But the results aren't saved in $CARGO_HOME/assets when a relative path was used.

Following the steps of:

  • Replacing: const MY_ASSET: &str = mg!(file("./src/yew.svg"));
  • With: const MY_ASSET: &str = mg!(file("src/yew.svg"));
  • And then replacing it again with: const MY_ASSET: &str = mg!(file("./src/yew.svg"));

Gets things sort of working.

Once the ./ is removed the assets information is stored in $CARGO_HOME/assets/package_name-package_name-0.1 and, $CARGO_HOME/assets/package_name-0.1 (not sure if this was intentional). But only $CARGO_HOME/assets/package_name-0.1 is actually being read as far as I can tell. Afterwards switching between using "./" and just the file path directly also causes a duplicate insertion in $CARGO_HOME/assets/package_name-0.1/assets.toml.

Environment:

  • Manganis version: 0.2.2
  • Rust version: 1.77.1
  • OS info: Endeavour OS
  • App platform: web via trunk

airblast-dev avatar Apr 19 '24 14:04 airblast-dev

This was fixed in https://github.com/DioxusLabs/collect-assets/pull/30

ealmloff avatar Jul 03 '24 17:07 ealmloff