From bcaee279afdecc1d033be106e0d545426fe5cf60 Mon Sep 17 00:00:00 2001 From: Keith Smith Date: Thu, 20 Mar 2014 12:05:41 -0600 Subject: [PATCH] added support for adding custom paths to source files when passing in strings to uglify --- tools/node.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/node.js b/tools/node.js index bef296ea..917c35c6 100644 --- a/tools/node.js +++ b/tools/node.js @@ -59,7 +59,8 @@ exports.minify = function(files, options) { warnings : false, mangle : {}, output : null, - compress : {} + compress : {}, + sourcePaths : [] }); UglifyJS.base54.reset(); @@ -72,13 +73,16 @@ exports.minify = function(files, options) { } else { if (typeof files == "string") files = [ files ]; - files.forEach(function(file){ + files.forEach(function(file, index){ var code = options.fromString ? file : fs.readFileSync(file, "utf8"); + var filename = options.fromString + ? options.sourcePaths[index] || "?" + : file; sourcesContent[file] = code; toplevel = UglifyJS.parse(code, { - filename: options.fromString ? "?" : file, + filename: filename, toplevel: toplevel }); });