Only compress web assets in the CLI (#2329)

* only compress web assets in the CLI

* precompressed -> pre-compressed

* only enable pre-compression in release builds
This commit is contained in:
Evan Almloff authored and GitHub committed 2024-04-26 00:47:04 -04:00
1 parent b147f5a737
commit a27d4e71ed
13 files changed
+461 -468

No files matched your search

+9
View File
@@ -211,6 +211,7 @@ impl Default for DioxusConfig {
key_path: None,
cert_path: None,
},
pre_compress: true,
},
bundle: BundleConfig {
identifier: Some(format!("io.github.{name}")),
@@ -280,6 +281,9 @@ pub struct WebConfig {
pub resource: WebResourceConfig,
#[serde(default)]
pub https: WebHttpsConfig,
/// Whether to enable pre-compression of assets and wasm during a web build in release mode
#[serde(default = "true_bool")]
pub pre_compress: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -571,6 +575,11 @@ impl CrateConfig {
self.add_features(features);
self
}
/// Check if assets should be pre_compressed. This will only be true in release mode if the user has enabled pre_compress in the web config.
pub fn should_pre_compress_web_assets(&self) -> bool {
self.dioxus_config.web.pre_compress && self.release
}
}
fn true_bool() -> bool {