Skip to content
This repository was archived by the owner on Nov 19, 2018. It is now read-only.

Commit 678eec5

Browse files
author
Stefan
committed
@stefan-- added sourceRoot support PR gruntjs#136
1 parent 78a812d commit 678eec5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tasks/lib/sourcemap.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ exports.init = function(grunt) {
136136
// Add the lines of a given file to the sourcemap. If in the file, store a
137137
// prior sourcemap and return src with sourceMappingURL removed.
138138
SourceMapConcatHelper.prototype.addlines = function(src, filename) {
139-
var relativeFilename = path.relative(path.dirname(this.dest), filename);
139+
var destDirectory = path.dirname(this.dest),
140+
relativeFilename = path.relative(destDirectory, filename);
140141
// sourceMap path references are URLs, so ensure forward slashes are used for paths passed to sourcemap library
141142
relativeFilename = relativeFilename.replace(/\\/g, '/');
142143
if (
@@ -162,7 +163,7 @@ exports.init = function(grunt) {
162163
var sourceMap = JSON.parse(sourceContent);
163164
var sourceMapConsumer = new SourceMapConsumer(sourceMap);
164165
// Consider the relative path from source files to new sourcemap.
165-
var sourcePathToSourceMapPath = path.relative(path.dirname(this.dest), sourceMapDir);
166+
var sourcePathToSourceMapPath = path.relative(destDirectory, sourceMapConsumer.sourceRoot || path.dirname(sourceMapPath));
166167
// Transfer the existing mappings into this mapping
167168
var initLine = this.line;
168169
var initCol = this.column;

0 commit comments

Comments
 (0)