Fix is_release_profile Logic (#4091)
* fix `is_release_profile` logic * fix: don't merge wasm-split modules with asset system, don't compress randomly --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
06aaf15d83
commit
18477a0373
2 files changed
+11
-7
No files matched your search
@@ -2953,7 +2953,7 @@ impl BuildRequest {
|
||||
/// 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.
|
||||
fn should_pre_compress_web_assets(&self, release: bool) -> bool {
|
||||
self.config.web.pre_compress && release
|
||||
self.config.web.pre_compress & release
|
||||
}
|
||||
|
||||
/// Bundle the web app
|
||||
@@ -3147,7 +3147,7 @@ impl BuildRequest {
|
||||
|
||||
// In release mode, we make the wasm and bindgen files into assets so they get bundled with max
|
||||
// optimizations.
|
||||
let wasm_path = if self.release {
|
||||
let wasm_path = if self.release && !should_bundle_split {
|
||||
// Register the main.js with the asset system so it bundles in the snippets and optimizes
|
||||
let name = assets.register_asset(
|
||||
&self.wasm_bindgen_js_output_file(),
|
||||
@@ -3159,7 +3159,7 @@ impl BuildRequest {
|
||||
format!("wasm/{}", asset.file_name().unwrap().to_str().unwrap())
|
||||
};
|
||||
|
||||
let js_path = if self.release {
|
||||
let js_path = if self.release && !should_bundle_split {
|
||||
// Make sure to register the main wasm file with the asset system
|
||||
let name = assets.register_asset(&post_bindgen_wasm, AssetOptions::Unknown)?;
|
||||
format!("assets/{}", name.bundled_path())
|
||||
|
||||
@@ -107,16 +107,16 @@ impl Workspace {
|
||||
}
|
||||
|
||||
pub fn is_release_profile(&self, profile: &str) -> bool {
|
||||
if profile == "release" {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the profile inherits from release by traversing the `inherits` chain
|
||||
let mut current_profile_name = profile;
|
||||
|
||||
// Try to find the current profile in the custom profiles section
|
||||
while let Some(profile_settings) = self.cargo_toml.profile.custom.get(current_profile_name)
|
||||
{
|
||||
if profile == "release" {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check what this profile inherits from
|
||||
match &profile_settings.inherits {
|
||||
// Otherwise, continue checking the profile it inherits from
|
||||
@@ -126,6 +126,10 @@ impl Workspace {
|
||||
// Since it didn't lead to "release", return false.
|
||||
None => break,
|
||||
}
|
||||
|
||||
if current_profile_name == "release" {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
|
||||
Reference in new issue
Block a user