Simplify cli-config, hotreload -> devtools (drop to 0 deps, fast compile times) (#2975)
* simplify cli-config crate * clean up configs * add devtools crate, update cargo imports * fix serve addr, fix websocket proxy issue * add comment about opt profiles * rename hot-reload to devtools
This commit is contained in:
1 parent
8203ee571f
commit
3fb1f739d1
58 files changed
+1131
-1654
No files matched your search
@@ -18,8 +18,8 @@ dioxus-ssr = { workspace = true, optional = true }
|
||||
dioxus-isrg = { workspace = true, optional = true }
|
||||
axum = { workspace = true, features = ["ws", "macros"], optional = true }
|
||||
tower-http = { workspace = true, features = ["fs"], optional = true }
|
||||
dioxus-hot-reload = { workspace = true, features = ["serve"], optional = true }
|
||||
dioxus-cli-config = { workspace = true, features = ["read-config"], optional = true }
|
||||
dioxus-devtools = { workspace = true, optional = true }
|
||||
dioxus-cli-config = { workspace = true, optional = true }
|
||||
dioxus-web = { workspace = true, features = ["hydrate"], optional = true }
|
||||
tokio = { workspace = true, optional = true }
|
||||
http = { workspace = true, optional = true }
|
||||
@@ -32,7 +32,7 @@ criterion = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
server = ["dioxus-fullstack/server", "dioxus-router/ssr", "dep:dioxus-ssr", "dep:tokio", "dep:http", "dep:axum", "dep:tower-http", "dep:dioxus-hot-reload", "dep:dioxus-cli-config", "dep:tower", "dep:dioxus-isrg"]
|
||||
server = ["dioxus-fullstack/server", "dioxus-router/ssr", "dep:dioxus-ssr", "dep:tokio", "dep:http", "dep:axum", "dep:tower-http", "dep:dioxus-devtools", "dep:dioxus-cli-config", "dep:tower", "dep:dioxus-isrg"]
|
||||
web = ["dioxus-fullstack/web", "dioxus-router/web", "dep:dioxus-web"]
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
|
||||
@@ -41,19 +41,12 @@ pub fn launch(
|
||||
.unwrap();
|
||||
|
||||
// Serve the program if we are running with cargo
|
||||
if std::env::var_os("CARGO").is_some() || std::env::var_os("DIOXUS_ACTIVE").is_some() {
|
||||
if std::env::var_os("CARGO").is_some() || dioxus_cli_config::is_cli_enabled() {
|
||||
// Get the address the server should run on. If the CLI is running, the CLI proxies static generation into the main address
|
||||
// and we use the generated address the CLI gives us
|
||||
let cli_args = dioxus_cli_config::RuntimeCLIArguments::from_cli();
|
||||
let address = cli_args
|
||||
.as_ref()
|
||||
.map(|args| args.fullstack_address().address())
|
||||
.unwrap_or_else(|| std::net::SocketAddr::from(([127, 0, 0, 1], 8080)));
|
||||
let serve_address = dioxus_cli_config::fullstack_address_or_localhost();
|
||||
|
||||
// Point the user to the CLI address if the CLI is running or the fullstack address if not
|
||||
let serve_address = cli_args
|
||||
.map(|args| args.cli_address())
|
||||
.unwrap_or_else(|| address);
|
||||
println!(
|
||||
"Serving static files from {} at http://{serve_address}",
|
||||
path.display()
|
||||
@@ -77,7 +70,7 @@ pub fn launch(
|
||||
})))
|
||||
};
|
||||
|
||||
let listener = tokio::net::TcpListener::bind(address).await.unwrap();
|
||||
let listener = tokio::net::TcpListener::bind(serve_address).await.unwrap();
|
||||
axum::serve(listener, router.into_make_service())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@@ -65,10 +65,7 @@ pub async fn generate_static_site(
|
||||
}
|
||||
|
||||
// Copy over the web output dir into the static output dir
|
||||
let assets_path = dioxus_cli_config::CURRENT_CONFIG
|
||||
.as_ref()
|
||||
.map(|c| c.application.out_dir.clone())
|
||||
.unwrap_or("./dist".into());
|
||||
let assets_path = dioxus_cli_config::out_dir().unwrap_or("./dist".into());
|
||||
|
||||
let assets_path = assets_path.join("public");
|
||||
|
||||
|
||||
Reference in new issue
Block a user