diff --git a/src/sourcemaps/scanner.js b/src/sourcemaps/scanner.js index d5e558a..c5ccc13 100644 --- a/src/sourcemaps/scanner.js +++ b/src/sourcemaps/scanner.js @@ -37,17 +37,27 @@ class Scanner { } extractMapPath(file) { + // check sourceMappingURL to see if a map is defined const mapPath = this.parseMapPath(file.filePathName); - - if(mapPath) { + if (mapPath) { output.status('', mapPath); file.mapPathName = mapPath; file.sourceMappingURL = true; file.mappedFile = path.join(this.targetPath, mapPath); + return; + } - } else { - output.warn('', 'map not found'); + // check to see if the file exists locally + const localPath = this.localMapPath(file.filePathName); + if (localPath) { + output.status('', localPath); + file.mapPathName = localPath; + file.sourceMappingURL = false; + file.mappedFile = path.join(this.targetPath, localPath); + return; } + + output.warn('', 'map not found'); } async loadMapData(file) { @@ -190,6 +200,12 @@ class Scanner { } } } + + localMapPath(sourcePath) { + const mapPath = sourcePath + '.map'; + const stat = fs.statSync(mapPath, { throwIfNoEntry: false }); + return stat && stat.isFile() ? path.basename(mapPath) : undefined; + } } module.exports = Scanner;