Skip to content

Implement #5568 fullstack embedding of the assets in the binary#5569

Open
mkg20001 wants to merge 8 commits into
DioxusLabs:mainfrom
mkg20001:feat/embed
Open

Implement #5568 fullstack embedding of the assets in the binary#5569
mkg20001 wants to merge 8 commits into
DioxusLabs:mainfrom
mkg20001:feat/embed

Conversation

@mkg20001
Copy link
Copy Markdown

See issue #5568 for context

This adds a new --embed flag, that can be used to embed the assets of a web fullstack server in the binary directly using rust-embed.

This also adds a new feature named embed, to actually enable the embedding, that gets enabled when --embed is set.

@mkg20001 mkg20001 requested a review from a team as a code owner May 19, 2026 16:12
mkg20001 and others added 8 commits May 21, 2026 14:34
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When the `embed` feature is enabled, `serve_static_assets()` serves
assets from a rust-embed bundle compiled into the binary instead of
reading from the filesystem. This enables single-binary deployment
of fullstack apps.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds `--embed` to `dx build` and `dx serve` that:
- Sets embed_assets/embed_dir on the server BuildRequest
- Pushes the "embed" feature to the server build
- Sets DIOXUS_EMBED_DIR env var for rust-embed at compile time
- Forces sequential builds (client must complete before server)
- Validates that --embed requires a fullstack build

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests that:
- --embed with fullstack sets embed_assets, embed_dir, and embed feature on server
- --embed without fullstack produces an error

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix needless_return in serve_static_assets cfg blocks
- Apply rustfmt formatting to embedded.rs and build.rs
- Update Cargo.lock with new dependencies

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When the embed feature is enabled but DIOXUS_EMBED_DIR is not set
(e.g. during cargo clippy --all-features or IDE checks), provide an
empty directory so rust-embed's derive macro compiles with zero assets.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ServeConfig::new() was reading index.html from the filesystem via
public_path(), which doesn't exist when assets are embedded. Without
it, the SSR fallback produces a bare HTML skeleton with no JS/WASM
script tags, so the app never hydrates on the client.

Now checks embedded assets first when the embed feature is active,
falling back to filesystem and then ssr_only() as before.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

1 participant