From df9ec5fe5dc518b80374e815acaff55f0d5a4d7f Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Wed, 6 Jul 2016 21:07:26 +0200 Subject: [PATCH 1/2] Add support for sourcemaproot --- tasks/concat.js | 3 ++- tasks/lib/sourcemap.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tasks/concat.js b/tasks/concat.js index 81fd862..b7c9d09 100644 --- a/tasks/concat.js +++ b/tasks/concat.js @@ -25,7 +25,8 @@ module.exports = function(grunt) { process: false, sourceMap: false, sourceMapName: undefined, - sourceMapStyle: 'embed' + sourceMapStyle: 'embed', + sourceMapRoot: undefined }); // Normalize boolean options that accept options objects. diff --git a/tasks/lib/sourcemap.js b/tasks/lib/sourcemap.js index 6c36473..3c7f82c 100644 --- a/tasks/lib/sourcemap.js +++ b/tasks/lib/sourcemap.js @@ -32,7 +32,8 @@ exports.init = function(grunt) { // ensure we're using forward slashes, because these are URLs var file = path.relative(path.dirname(this.dest), this.files.dest).replace(/\\/g, '/'); var generator = new SourceMapGenerator({ - file: file + file: file, + sourceRoot: this.options.sourceMapRoot }); this.file = file; this.generator = generator; From ec107bb2290e449b985525d6dd916c9dd5f8fdda Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Thu, 7 Jul 2016 08:34:31 +0200 Subject: [PATCH 2/2] Added test for sourcemaproot --- Gruntfile.js | 14 ++++++++++++++ test/concat_test.js | 6 +++++- test/expected/sourcemap4_embed_map.map | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/expected/sourcemap4_embed_map.map diff --git a/Gruntfile.js b/Gruntfile.js index 08cff05..98c70f5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -127,6 +127,20 @@ module.exports = function(grunt) { ] } }, + sourcemap4_options: { + options: { + sourceMap: true, + sourceMapName: 'tmp/sourcemap4_embed_map.map', + sourceMapRoot: 'file://tmp' + }, + files: { + 'tmp/sourcemap4_embed': [ + 'test/fixtures/mappedsource_embed', + 'test/fixtures/file1', + 'test/fixtures/file2' + ] + } + }, sourcemap_js: { options: { banner: '/*\nJS Banner\n*/\n', diff --git a/test/concat_test.js b/test/concat_test.js index 3de58d6..cded92a 100644 --- a/test/concat_test.js +++ b/test/concat_test.js @@ -83,7 +83,7 @@ exports.concat = { test.done(); }, sourcemap_options: function(test) { - test.expect(5); + test.expect(6); var actual = getNormalizedFile('tmp/sourcemap_inline'); var expected = getNormalizedFile('test/expected/sourcemap_inline'); @@ -105,6 +105,10 @@ exports.concat = { expected = getNormalizedFile('test/expected/sourcemap_css.css.map'); test.equal(actual, expected, 'should output the css map.'); + actual = getNormalizedFile('tmp/sourcemap4_embed_map.map'); + expected = getNormalizedFile('test/expected/sourcemap4_embed_map.map'); + test.equal(actual, expected, 'should include sourceRoot.'); + test.done(); } }; diff --git a/test/expected/sourcemap4_embed_map.map b/test/expected/sourcemap4_embed_map.map new file mode 100644 index 0000000..de93916 --- /dev/null +++ b/test/expected/sourcemap4_embed_map.map @@ -0,0 +1 @@ +{"version":3,"sources":["../test/fixtures/file1","../test/fixtures/mappedsource_embed","../test/fixtures/file2"],"names":[],"mappings":"AAAA;ACCA,E;ADDA;AEAA","file":"sourcemap4_embed","sourceRoot":"file://tmp","sourcesContent":["file1","file1","file2"]} \ No newline at end of file