added support for adding custom paths to source files when passing in strings to uglify

This commit is contained in:
Keith Smith 2014-03-20 12:05:41 -06:00
parent 448a8d3845
commit bcaee279af

View File

@ -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
});
});