Просмотр исходного кода

integrate with the bundle command

Evan Almloff 1 год назад
Родитель
Сommit
9bfe9682b5
2 измененных файлов с 15 добавлено и 2 удалено
  1. 2 2
      packages/cli/src/builder.rs
  2. 13 0
      packages/cli/src/cli/bundle.rs

+ 2 - 2
packages/cli/src/builder.rs

@@ -252,8 +252,6 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
 pub fn build_desktop(config: &CrateConfig, _is_serve: bool) -> Result<BuildResult> {
     log::info!("🚅 Running build [Desktop] command...");
 
-    let _gaurd = AssetConfigDropGaurd::new();
-
     let t_start = std::time::Instant::now();
     let ignore_files = build_assets(config)?;
 
@@ -353,6 +351,8 @@ pub fn build_desktop(config: &CrateConfig, _is_serve: bool) -> Result<BuildResul
         }
     }
 
+    // Collect assets
+    process_assets(config)?;
     // Create the __assets_head.html file for bundling
     create_assets_head(&config)?;
 

+ 13 - 0
packages/cli/src/cli/bundle.rs

@@ -128,6 +128,19 @@ impl Bundle {
             }
         }
 
+        // Add all assets from collect assets to the bundle
+        {
+            let config = assets_cli_support::Config::current();
+            let location = config.assets_serve_location().to_string();
+            let location = format!("./{}", location);
+            println!("Adding assets from {} to bundle", location);
+            if let Some(resources) = &mut bundle_settings.resources {
+                resources.push(location);
+            } else {
+                bundle_settings.resources = Some(vec![location]);
+            }
+        }
+
         let mut settings = SettingsBuilder::new()
             .project_out_directory(crate_config.out_dir)
             .package_settings(PackageSettings {