Add sourceRoot option to minify
authorSergej Tatarincev <st@bekitzur.com>
Fri, 19 Oct 2012 09:35:19 +0000 (12:35 +0300)
committerSergej Tatarincev <st@bekitzur.com>
Fri, 19 Oct 2012 09:35:19 +0000 (12:35 +0300)
README.md
tools/node.js

index f519c11..4bf29b2 100644 (file)
--- a/README.md
+++ b/README.md
@@ -343,6 +343,14 @@ Note that the source map is not saved in a file, it's just returned in
 `result.map`.  The value passed for `outSourceMap` is only used to set the
 `file` attribute in the source map (see [the spec][sm-spec]).
 
+You can also specify sourceRoot property to be included in source map:
+
+    var result = UglifyJS.minify([ "file1.js", "file2.js", "file3.js" ], {
+        outSourceMap: "out.js.map",
+        sourceRoot: "http://example.com/src"
+    });
+
+
 If you're compressing compiled JavaScript and have a source map for it, you
 can use the `inSourceMap` argument:
 
index 6a21710..80cc185 100644 (file)
@@ -65,6 +65,7 @@ for (var i in UglifyJS) {
 exports.minify = function(files, options) {
     options = UglifyJS.defaults(options, {
         outSourceMap : null,
+        sourceRoot   : null,
         inSourceMap  : null,
         fromString   : false,
         warnings     : false,
@@ -104,7 +105,8 @@ exports.minify = function(files, options) {
     }
     if (options.outSourceMap) map = UglifyJS.SourceMap({
         file: options.outSourceMap,
-        orig: inMap
+        orig: inMap,
+        root: options.sourceRoot
     });
     var stream = UglifyJS.OutputStream({ source_map: map });
     toplevel.print(stream);