collect-assets
collect-assets copied to clipboard
Manganis Fails To Provide Assets In Workspaces & Examples
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
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:
webviatrunk
This was fixed in https://github.com/DioxusLabs/collect-assets/pull/30