diff --git a/crates/mako/src/resolve.rs b/crates/mako/src/resolve.rs index f283eba13..71ece577c 100644 --- a/crates/mako/src/resolve.rs +++ b/crates/mako/src/resolve.rs @@ -280,7 +280,7 @@ fn do_resolve( } _ => { eprintln!( - "failed to resolve {} from {} with resolver err: {:?}", + "failed to resolve `{}` from `{}` with resolver err: {:?}", source, path.to_string_lossy(), oxc_resolve_err diff --git a/crates/mako/src/visitors/css_assets.rs b/crates/mako/src/visitors/css_assets.rs index 2a8b7155a..7066e4f04 100644 --- a/crates/mako/src/visitors/css_assets.rs +++ b/crates/mako/src/visitors/css_assets.rs @@ -28,10 +28,12 @@ impl VisitMut for CSSAssets { box UrlValue::Raw(s) => s.value.to_string(), }; - if is_remote_or_data_or_hash(&url) { + if is_remote_or_data_or_hash(&url) || url.is_empty() { return; } + let url = remove_first_tilde(url); + let dep = Dependency { source: url, resolve_as: None, @@ -110,6 +112,14 @@ mod tests { ); } + #[test] + fn test_empty_url() { + assert_eq!( + run(r#".foo { background: url("") }"#), + r#".foo{background:url("")}"# + ); + } + #[test] fn test_big_image() { assert!(run(r#".foo { background: url(big.jpg) }"#).contains(".foo{background:url(big."));