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

[Desktop] Asset inclusion not working #2345

Open
1 of 3 tasks
Anonyfox opened this issue Apr 19, 2024 · 5 comments
Open
1 of 3 tasks

[Desktop] Asset inclusion not working #2345

Anonyfox opened this issue Apr 19, 2024 · 5 comments

Comments

@Anonyfox
Copy link

Problem

Steps To Reproduce

Steps to reproduce the behavior:

  • new desktop app with dx new
  • with router
  • vanilla css
    • dx serve

... the CSS from main.css is not loaded at all.

  • tried more explicit with setting in Dioxus.toml:
...
# include `assets` in web platform
[web.resource]

# CSS style file

style = ["assets/main.css"]

# Javascript code file
script = []
...

no difference.

  • after some tweaking with the paths, I also get (consistently) the error:
[ERROR] dioxus_desktop::protocol - Failed to read "/path/to/my/crate/dist/dist/__assets_head.html": No such file or directory (os error 2)

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

Bildschirmfoto 2024-04-19 um 20 33 53

Environment:

  • Dioxus version: v0.5
  • Rust version: rustc 1.77.2 (25ef9e3d8 2024-04-09)
  • OS info: MacOS Sonoma 14.4
  • App platform: desktop]

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later
@terhechte
Copy link
Contributor

I have the same issue when using it for a web project. I did find a workout, but its more of a hack tbh.:
Install Manganis so that it can embed the css for you. This, however, will not work yet. Changing the css will not force a recompile that incorporates the css. So I added an unnamed number variable below. Increasing the number will force a recompile and any changes you made to your css will be picked up.

const _: &str = manganis::mg!(file("./assets/main.css"));
const _: &str = "2";

Note that I get a rust-analyser error for the first line (file not found) but it compiles just fine with dx...

@thurn
Copy link

thurn commented May 3, 2024

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

dioxus = { version = "0.5.2", features = ["desktop"], git = "https://github.com/DioxusLabs/dioxus.git" }

So possibly this issue has recently been fixed and we're just waiting for a release?

@mrguiman
Copy link

mrguiman commented May 3, 2024

Same problem here when serving on macOS. This looks like a macOS specific issue, as our project still works fine when building on linux

@Libq2022
Copy link

Libq2022 commented May 7, 2024

According to examples, I add this line to App component, and solve the problem.
style { {include_str!("../assets/main.css")} }

@avi-cenna
Copy link

I am having the same issue on Mac, but I can confirm that the include_str macro does work, per the comment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants