Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind committed Oct 30, 2024
1 parent 8edfc19 commit ae0512e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions crates/rspack_plugin_devtool/src/source_map_dev_tool_plugin.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::path::{Component, PathBuf};
use std::sync::LazyLock;
use std::{borrow::Cow, path::Path};

Expand Down Expand Up @@ -417,12 +418,18 @@ impl SourceMapDevToolPlugin {
let source_map_url = if let Some(public_path) = &self.public_path {
format!("{public_path}{source_map_filename}")
} else {
let mut file_path = PathBuf::new();
file_path.push(Component::RootDir);
file_path.extend(Path::new(filename.as_ref()).components());

let mut source_map_path = PathBuf::new();
source_map_path.push(Component::RootDir);
source_map_path.extend(Path::new(&source_map_filename).components());

relative(
#[allow(clippy::unwrap_used)]
&Path::new(&format!("/{}", filename.as_ref()))
.parent()
.unwrap(),
&Path::new(&format!("/{}", &source_map_filename)),
file_path.parent().unwrap(),
&source_map_path,
)
.to_string_lossy()
.to_string()
Expand Down

0 comments on commit ae0512e

Please sign in to comment.