diff --git a/crates/rspack_plugin_devtool/src/source_map_dev_tool_plugin.rs b/crates/rspack_plugin_devtool/src/source_map_dev_tool_plugin.rs index 2d6bfb787c1b..68d4210f7e16 100644 --- a/crates/rspack_plugin_devtool/src/source_map_dev_tool_plugin.rs +++ b/crates/rspack_plugin_devtool/src/source_map_dev_tool_plugin.rs @@ -407,8 +407,8 @@ impl SourceMapDevToolPlugin { let chunk = file_to_chunk.get(&source_filename); let filename = match &self.file_context { Some(file_context) => Cow::Owned( - Path::new(file_context) - .relative(Path::new(&source_filename)) + Path::new(&source_filename) + .relative(Path::new(file_context)) .to_string_lossy() .to_string(), ), @@ -454,10 +454,8 @@ impl SourceMapDevToolPlugin { source_map_path.extend(Path::new(&source_map_filename).components()); #[allow(clippy::unwrap_used)] - file_path - .parent() - .unwrap() - .relative(&source_map_path) + source_map_path + .relative(file_path.parent().unwrap()) .to_string_lossy() .to_string() };