-
-
Notifications
You must be signed in to change notification settings - Fork 932
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
[Desktop] Asset inclusion not working #2345
Comments
I have the same issue when using it for a web project. I did find a workout, but its more of a hack tbh.:
Note that I get a rust-analyser error for the first line (file not found) but it compiles just fine with |
Also seeing this. The tailwind example doesn't work at all on desktop on the current version (0.5.1) but it does work on master when using
So possibly this issue has recently been fixed and we're just waiting for a release? |
Same problem here when serving on macOS. This looks like a macOS specific issue, as our project still works fine when building on linux |
According to examples, I add this line to App component, and solve the problem. |
I am having the same issue on Mac, but I can confirm that the include_str macro does work, per the comment above. |
I'm having the same issue on MacOS, but it looks like @ealmloff fixed it today in 7efe4d0e49c351545ba #51545ba as part of #2419. 🎉 Running ❯ dx serve --hot-reload --platform desktop
Dioxus @ v0.5.4 [21:40:59]
> Hot Reload Mode: RSX
> Watching: [ src, assets, Cargo.toml, Dioxus.toml ]
> Custom index.html: None
> Serve index.html on 404: True
> Build Features: [ ]
> Build Profile: Debug
> Build took: 6937 millis
dioxus = { git = "https://github.com/DioxusLabs/dioxus", features = ["desktop"], branch = "main"} |
i am still getting this error on macbook. tried it on 2 different computers to make sure it's not my fault. I've tried tailwind and css and neither styles work. |
Having the same issue on Ubuntu. Can confirm @Libq2022's approach fixes it. |
I'm having this problem too. |
The Answer gave me some Idea so: |
@D0bhareach there is no section And from the wording, this seems to be for web platform not desktop. But glad you got it working, doesn't work for me. |
Only way I got it working - take a look at the You need your fn main() {
// Init logger
dioxus_logger::init(Level::INFO).expect("failed to init logger");
let config = dioxus::desktop::Config::new()
.with_custom_head(r#"<link rel="stylesheet" href="main.css">"#.to_string());
LaunchBuilder::desktop().with_cfg(config).launch(App);
//dioxus::launch(App);
} However, there are styling issues apparently. Some stuff like header color seems to be missing, other stuff doesn't work - the links from the router are not styled properly because they rely on an ID Btw since some time has passed, my results are |
Look what I've got 😁 I misunderstood the Buttons still look shite, might try to fix but my CSS is low. HTH/enjoy |
This should be resolved with the combination of fixes to manganis in DioxusLabs/manganis#30 and Head elements added in #2635. You can install the git version of the CLI with:
and the git version of manganis and dioxus with:
Then you can include CSS in the head with a Link anywhere in a component: use dioxus::prelude::*;
fn main() {
launch(|| {
rsx! {
// Make the background red
head::Link {
href: manganis::mg!(file("./test.css")),
rel: "stylesheet",
}
}
});
} Or other assets with the manganis macro: use dioxus::prelude::*;
fn main() {
launch(|| {
rsx! {
// Display an image
img {
src: manganis::mg!(file("./img.png"))
}
}
});
} |
Doesn't work at least not in Windows, but anyway. Point was that a template generating CLI should generate the full sample, not part of it. The vanilla CSS ships with And |
Following these steps with the stable version of Dioxus did style things correctly on macos:
If you are using the git version of dioxus, you will need to install the git version of the CLI and manually update the code from the template with the changes I listed above or use this branch of the template. The new way to include assets with If this isn't working on windows, it would be very helpful to know what the current working directory of the desktop app is when you run it with dx serve (relative to the package root) and what path the webview tries to load for your asset. Absolute paths don't work on windows (#1814) which could be the issue or there could be a path separator issue |
Damn, something went wrong with the scaling and cropped it - I tried to make a video in a dev VM because it is easier, sadly parts of the command window and the But the error message can still be seen at 01:26, also the effect of copying files around and launching the I also now understand that and why the router-template is broken in regard to styling. Here a separate screenshot of the error message in full. HTH |
Problem
Steps To Reproduce
Steps to reproduce the behavior:
dx new
... the CSS from main.css is not loaded at all.
Dioxus.toml
:no difference.
where it clearly adds the
/dist
part twice. the file does exist in the dist folder at the correct location on my disk, no idea whats wrong here. no idea whats wrong. No success with removing that error so far.Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
Environment:
desktop
]Questionnaire
The text was updated successfully, but these errors were encountered: