DioxusLabs / DioxusLabs/dioxus

Development experience improvements for workspaces

Open
#3,305 4 comments 3 reactions 0 assignees View on GitHub
cli documentation
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

Hello,
I really like Dioxus, but there are a number of small, niggly issues that I keep bumping against. I know you're iterating fast, but I wanted to collect my experiences adding Dioxus to an existing project here.

Despite these issues below, Dioxus fucking rocks 🚀. It's fantastic, honestly. Once set up it is so simple to build amazing things, I really love it. But I wanted to highlight some specific issues I encountered when setting up a new project that might be confusing to those who are new to Dioxus, or are returning after not having used it in a while:

- The search result component in the docs is quite confusing: perhaps we should include the page subtitle?
- Search results in docs pull up results for unsupported versions of Dioxus
- `dx new` should include some specific descriptions of the different template types, the names are not super descriptive.
- The latest tailwind docs have an incorrect `npx` command: it should be `npx tailwindcss -i ./input.css -o ./assets/tailwind.css --watch` (the `./assets/` part is changed from `./public/`)
- Workspaces are still confusing: every project I've used Dioxus with has been in the context of a workspace - I want to add a web/native frontend to a project that includes a CLI and/or a library
- The `workspace` template should be used for a _new_ workspace, not if you're in a _existing_ workspace
- Custom build profiles don't seem to work: WASM optimizations need to be set on the `release` profile, not a specific `wasm-release` profile
- You apparently need to `cd` into a specific package directory to run `dx serve`, but it seems to work without

### Full story

The first issue is that the docs say 0.6.0 is an alpha version, but 0.6.0 seems to be out? It came out very recently, but it's confusing.

Screenshot 2024-12-08 at 14 19 16

I saw that there is a new workspace template (this is _fantastic_!), but after running `dx new` I'm greeted with the following list of options. The problem is that I've got no idea what `jumpstart` is - I can figure out what "barebones" and "workspace" likely is, but what's jumpstart? Including some descriptions on these would be good.

Screenshot 2024-12-08 at 14 19 36

I selected "workspace" because, well, I'm in a workspace. But this added the dioxus installation as a _new workspace_ under my current workspace! The crates are spread out, which is quite nice.

Ok, no problem. I can merge the crates into my workspace. All the docs say I need to `cd` into the workspace member directory then run `dx serve` - but it's not clear why. When working in a workspace this is kind of annoying.

Ok, so let's try to use the `-p` flag instead:

```shell
$ dx serve -p web
0.418s ERROR Loading crate
0.418s ERROR Found package NodeIndex(499)
0.418s ERROR failed to read `dioxus/settings.toml` config file
0.418s ERROR Autodetecting platform from feature asset
...
0.419s ERROR Multiple platforms are enabled. Please specify a platform with `--platform ` or set a single default platform using a cargo feature.
0.419s ERROR - (MacOS, "desktop")
0.419s ERROR - (Web, "web")
0.420s ERROR err=Other(No platform was specified and could not be auto-detected. Please specify a platform with `--platform ` or set a default platform using a cargo feature.)
```

Weird - the package has a default feature set, but that's fine. We can run with `--platform=web` and it works.

But when building it outputs an error despite passing `--platform` - the error doesn't seem to actually stop the build, but it's confusing:

```shell
$ dx build -p web --platform=web
0. 0s INFO Building project...
0.331s ERROR Multiple platforms are enabled. Please specify a platform with `--platform ` or set a single default platform using a cargo feature.
0.331s ERROR - (MacOS, "desktop")
0.331s ERROR - (Web, "web")
1.32s INFO Compiling [ 1/214]: build-script-build
1.32s INFO Compiling [ 3/214]: unicode_ident
```

Ok. So let's try building with [optimizations](https://dioxuslabs.com/learn/0.6/cookbook/optimizing). The [build config docs](https://dioxuslabs.com/learn/0.6/cookbook/optimizing#build-configuration) say to set some pretty standard values for the `release` profile, but I only want to use them for the WASM build and not for the general workspace build. So I copy them to a `wasm-release` profile:

```toml
[profile.wasm-release]
inherits = "release"
opt-level = "z"
...
```

and build:

```shell
$ dx build -p web --platform=web --profile=wasm-release
...
1.105s INFO Build completed successfully! 🚀 path="/xxx/target/dx/web/debug/web/public"
```

Hmm - it built in debug mode? Ok, let's try with `--release`:

```shell
$ dx build -p web --platform=web --profile=wasm-release -r
...
2.213s INFO Build completed successfully! 🚀 path="/xxx/target/dx/web/release/web/public"
```

This seems to ignore the `--profile` argument and just build in release?

Ok, so something is werid. Let's just roll back to a single crate and not use the workspace template. I do this, then after running `dx serve -p web` I'm immediately greeted with this error:

```shell
$ dx serve -p web
...
15:25:16 [cargo] error: Asset at /assets/tailwind.css doesn't exist: No such file or directory (os error 2
--> crates/web/src/main.rs:21:29
|
21 | const TAILWIND_CSS: Asset = asset!("/assets/tailwind.css");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `asset` (in Nightly builds, run with -Z macro-backtrace for more info
```

Ok, I know why (I need to run the tailwind daemon or somesuch), but I go to the docs and search for `tailwind`. the results are relevant, but the actual _content_ is useless:

Screenshot 2024-12-08 at 14 18 26

Ok, so I click the first result for `Tailwind` and I'm taken to the cookbook page for version 0.4.3?

Screenshot 2024-12-08 at 15 28 54

The second result takes me to the docs for 0.6.0. There it says to run `npx tailwindcss -i ./input.css -o ./public/tailwind.css --watch`, and add this:

```rs
use dioxus::prelude::*;

// Urls are relative to your Cargo.toml file
const TAILWIND_URL: Asset = asset!("/assets/tailwind.css");
```

But this doesn't seem to work - the watch command writes to `public/tailwind.css` not `assets/tailwind.css`.

Changing the command to `npx tailwindcss -i ./input.css -o ./assets/tailwind.css --watch` works.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.