Implement #5568 fullstack embedding of the assets in the binary#5569
Open
mkg20001 wants to merge 8 commits into
Open
Implement #5568 fullstack embedding of the assets in the binary#5569mkg20001 wants to merge 8 commits into
mkg20001 wants to merge 8 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.