Skip to content

Commit 5251b6f

Browse files
committed
decouple sourceMapIn from sourceMap.url
fixes #487
1 parent 2edfe0b commit 5251b6f

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

Gruntfile.js

+14
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,20 @@ module.exports = function(grunt) {
256256
}
257257
}
258258
},
259+
sourcemapin_customUrl: {
260+
files: {
261+
'tmp/sourcemapin_customUrl.js': ['test/fixtures/src/simple2.js']
262+
},
263+
options: {
264+
sourceMap: {
265+
includeSources: true,
266+
url: 'sourcemapin_customUrl.js.map'
267+
},
268+
sourceMapIn: function() {
269+
return 'test/fixtures/src/simple2.map';
270+
}
271+
}
272+
},
259273
expression_json: {
260274
files: {
261275
'tmp/expression.json': ['test/fixtures/src/simple.json']

tasks/uglify.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,18 @@ module.exports = function(grunt) {
118118
}
119119
}
120120

121-
if (options.sourceMap && generateSourceMapURL) {
121+
if (options.sourceMap) {
122122
if (typeof options.sourceMap !== 'object') {
123123
options.sourceMap = {};
124124
}
125-
if (generateSourceMapFilename) {
126-
options.sourceMap.filename = path.basename(f.dest);
127-
}
128125
if (options.sourceMapIn) {
129126
options.sourceMap.content = grunt.file.read(options.sourceMapIn);
130127
}
131128
// Calculate the path from the dest file to the sourcemap for sourceMap.url
132129
if (generateSourceMapURL) {
130+
if (generateSourceMapFilename) {
131+
options.sourceMap.filename = path.basename(f.dest);
132+
}
133133
var destToSourceMapPath = relativePath(f.dest, options.generatedSourceMapName);
134134
var sourceMapBasename = path.basename(options.generatedSourceMapName);
135135
options.sourceMap.url = uriPath(path.join(destToSourceMapPath, sourceMapBasename));

test/fixtures/expected/sourcemapin_customUrl.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixtures/expected/sourcemapin_customUrl.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/uglify_test.js

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ exports.contrib_uglify = {
4141
'sourcemapin.js',
4242
'sourcemapin.js.map',
4343
'sourcemap_sources.js.map',
44+
'sourcemapin_customUrl.js',
45+
'sourcemapin_customUrl.js.map',
4446
'sourcemapin_sources.js',
4547
'sourcemapin_sources.js.map',
4648
'sourcemaps_multiple1.js',

0 commit comments

Comments
 (0)