feat: add option.outFileName for JS API, if absense, sourceMap.file field will deduced

This commit is contained in:
1111hui
2016-10-29 15:21:28 +08:00
committed by Richard van Velzen
parent 2a9989dd18
commit 0a35acbbe7
3 changed files with 16 additions and 5 deletions

View File

@@ -41,6 +41,7 @@ exports.minify = function(files, options) {
options = UglifyJS.defaults(options, {
spidermonkey : false,
outSourceMap : null,
outFileName : null,
sourceRoot : null,
inSourceMap : null,
sourceMapUrl : null,
@@ -120,7 +121,8 @@ exports.minify = function(files, options) {
}
if (options.outSourceMap || options.sourceMapInline) {
output.source_map = UglifyJS.SourceMap({
file: options.outSourceMap,
// prefer outFileName, otherwise use outSourceMap without .map suffix
file: options.outFileName || (typeof options.outSourceMap === 'string' ? options.outSourceMap.replace(/\.map$/i, '') : null),
orig: inMap,
root: options.sourceRoot
});