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

Commit

Permalink
@stefan-- added sourceRoot support PR gruntjs#136
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan committed Dec 14, 2015
1 parent 78a812d commit 678eec5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tasks/lib/sourcemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ exports.init = function(grunt) {
// Add the lines of a given file to the sourcemap. If in the file, store a
// prior sourcemap and return src with sourceMappingURL removed.
SourceMapConcatHelper.prototype.addlines = function(src, filename) {
var relativeFilename = path.relative(path.dirname(this.dest), filename);
var destDirectory = path.dirname(this.dest),
relativeFilename = path.relative(destDirectory, filename);
// sourceMap path references are URLs, so ensure forward slashes are used for paths passed to sourcemap library
relativeFilename = relativeFilename.replace(/\\/g, '/');
if (
Expand All @@ -162,7 +163,7 @@ exports.init = function(grunt) {
var sourceMap = JSON.parse(sourceContent);
var sourceMapConsumer = new SourceMapConsumer(sourceMap);
// Consider the relative path from source files to new sourcemap.
var sourcePathToSourceMapPath = path.relative(path.dirname(this.dest), sourceMapDir);
var sourcePathToSourceMapPath = path.relative(destDirectory, sourceMapConsumer.sourceRoot || path.dirname(sourceMapPath));
// Transfer the existing mappings into this mapping
var initLine = this.line;
var initCol = this.column;
Expand Down

0 comments on commit 678eec5

Please sign in to comment.