Skip to content

Commit 471e1a2

Browse files
authored
make url only relative when no publicPath has been provided
1 parent a539f24 commit 471e1a2

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

lib/SourceMapDevToolPlugin.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,7 @@ class SourceMapDevToolPlugin {
188188
if(sourceMapFile.indexOf("[contenthash]") !== -1) {
189189
sourceMapFile = sourceMapFile.replace(/\[contenthash\]/g, crypto.createHash("md5").update(sourceMapString).digest("hex"));
190190
}
191-
let sourceMapUrl = (options.fileContext ? sourceMapFile : path.relative(path.dirname(file), sourceMapFile)).replace(/\\/g, "/");
192-
if(options.publicPath) {
193-
sourceMapUrl = options.publicPath + sourceMapUrl;
194-
}
191+
const sourceMapUrl = options.publicPath ? options.publicPath + sourceMapFile.replace(/\\/g, "/") : path.relative(path.dirname(file), sourceMapFile).replace(/\\/g, "/");
195192
if(currentSourceMappingURLComment !== false) {
196193
asset.__SourceMapDevToolData[file] = compilation.assets[file] = new ConcatSource(new RawSource(source), currentSourceMappingURLComment.replace(/\[url\]/g, sourceMapUrl));
197194
}

0 commit comments

Comments
 (0)