Closed luveti closed 2 weeks ago
Having a per platform dist directory allows one to run dx serve multiple times without the build failing.
dx serve
We're currently patching Dioxus.toml right before running dx serve to get around this:
Dioxus.toml
# serve desktop sed -i.bak 's|out_dir = ".*"|out_dir = "dist/desktop"|g' Dioxus.toml rm Dioxus.toml.bak dx serve --platform desktop # serve fullstack sed -i.bak 's|out_dir = ".*"|out_dir = "dist/fullstack"|g' Dioxus.toml rm Dioxus.toml.bak dx serve --platform fullstack
But this no longer works since this commit https://github.com/DioxusLabs/dioxus/commit/8b5ad5d925555c38fe2e6d823c51587e54424cb9. The cli now places files in the target/dx-dist directory. Our new workaround was going to be:
target/dx-dist
# serve desktop export CARGO_TARGET_DIR="target/desktop" dx serve --platform desktop # serve fullstack export CARGO_TARGET_DIR="target/fullstack" dx serve --platform fullstack
But the new code does not follow CARGO_TARGET_DIR, and instead uses the hard-coded value target.
CARGO_TARGET_DIR
target
Here's my change that makes use of CARGO_TARGET_DIR:
let mut dist_dir = crate_config.workspace_dir() .join(std::env::var("CARGO_TARGET_DIR").as_ref().map(|x| x.as_str()).unwrap_or("target")) .join("dx-dist");
Septimus has suggested including the platform at the end of the dist_dir could be a nice way to support this:
dist_dir
crate_config.dioxus_config.application.out_dir = dist_dir .join(crate_config.executable_name()) .join(self.platform().feature_name());
The hardcoded workspaceroot/target/dx-dist will also cause issues when there are more than one Dioxus project in the workspace.
workspaceroot/target/dx-dist
Closed by #2779
Feature Request
Having a per platform dist directory allows one to run
dx serve
multiple times without the build failing.We're currently patching
Dioxus.toml
right before runningdx serve
to get around this:But this no longer works since this commit https://github.com/DioxusLabs/dioxus/commit/8b5ad5d925555c38fe2e6d823c51587e54424cb9. The cli now places files in the
target/dx-dist
directory. Our new workaround was going to be:But the new code does not follow
CARGO_TARGET_DIR
, and instead uses the hard-coded valuetarget
.Implement Suggestion
Here's my change that makes use of
CARGO_TARGET_DIR
:Septimus has suggested including the platform at the end of the
dist_dir
could be a nice way to support this: