Skip to content

Commit

Permalink
decouple sourceMapIn from sourceMap.url
Browse files Browse the repository at this point in the history
fixes #487
  • Loading branch information
alexlamsl committed Oct 11, 2017
1 parent 2edfe0b commit 5251b6f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
14 changes: 14 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,20 @@ module.exports = function(grunt) {
}
}
},
sourcemapin_customUrl: {
files: {
'tmp/sourcemapin_customUrl.js': ['test/fixtures/src/simple2.js']
},
options: {
sourceMap: {
includeSources: true,
url: 'sourcemapin_customUrl.js.map'
},
sourceMapIn: function() {
return 'test/fixtures/src/simple2.map';
}
}
},
expression_json: {
files: {
'tmp/expression.json': ['test/fixtures/src/simple.json']
Expand Down
8 changes: 4 additions & 4 deletions tasks/uglify.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,18 @@ module.exports = function(grunt) {
}
}

if (options.sourceMap && generateSourceMapURL) {
if (options.sourceMap) {
if (typeof options.sourceMap !== 'object') {
options.sourceMap = {};
}
if (generateSourceMapFilename) {
options.sourceMap.filename = path.basename(f.dest);
}
if (options.sourceMapIn) {
options.sourceMap.content = grunt.file.read(options.sourceMapIn);
}
// Calculate the path from the dest file to the sourcemap for sourceMap.url
if (generateSourceMapURL) {
if (generateSourceMapFilename) {
options.sourceMap.filename = path.basename(f.dest);
}
var destToSourceMapPath = relativePath(f.dest, options.generatedSourceMapName);
var sourceMapBasename = path.basename(options.generatedSourceMapName);
options.sourceMap.url = uriPath(path.join(destToSourceMapPath, sourceMapBasename));
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/expected/sourcemapin_customUrl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/fixtures/expected/sourcemapin_customUrl.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions test/uglify_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ exports.contrib_uglify = {
'sourcemapin.js',
'sourcemapin.js.map',
'sourcemap_sources.js.map',
'sourcemapin_customUrl.js',
'sourcemapin_customUrl.js.map',
'sourcemapin_sources.js',
'sourcemapin_sources.js.map',
'sourcemaps_multiple1.js',
Expand Down

0 comments on commit 5251b6f

Please sign in to comment.