From b7647cbd4de355d6e0d77d957771ddfa2cf3c53d Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Fri, 8 Dec 2023 14:30:34 +0800 Subject: [PATCH] fix: add assets info --- crates/plugin_manifest/src/plugin.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/plugin_manifest/src/plugin.rs b/crates/plugin_manifest/src/plugin.rs index c2e6cab..99d79b9 100644 --- a/crates/plugin_manifest/src/plugin.rs +++ b/crates/plugin_manifest/src/plugin.rs @@ -17,6 +17,7 @@ pub struct ManifestPlugin; pub struct AssetsManifest { pub pages: HashMap>, pub entries: HashMap>, + pub assets: HashMap, pub public_path: String, } @@ -47,11 +48,20 @@ impl Plugin for ManifestPlugin { let mut assets_mainfest = AssetsManifest { pages: HashMap::new(), entries: HashMap::new(), + assets: HashMap::new(), public_path: public_path.to_string(), }; let entry_points = &compilation.entrypoints; let assets = &compilation.assets(); + assets.into_iter().for_each(|(_, asset)| { + let version = &asset.info.version; + let source_file = &asset.info.source_filename; + if let Some(name) = source_file { + assets_mainfest.assets.insert(name.to_string(), version.to_string()); + } + }); + entry_points.iter().for_each(|(name, _entry)| { let mut files: Vec = Vec::new(); compilation.entrypoint_by_name(name).chunks.iter().for_each(|chunk| {