aboutsummaryrefslogtreecommitdiff
path: root/tools/node.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node.js')
-rw-r--r--tools/node.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/tools/node.js b/tools/node.js
index 6712ccf6..a16169b1 100644
--- a/tools/node.js
+++ b/tools/node.js
@@ -44,6 +44,7 @@ exports.minify = function(files, options) {
sourceRoot : null,
inSourceMap : null,
sourceMapUrl : null,
+ sourceMapInline : false,
fromString : false,
warnings : false,
mangle : {},
@@ -117,7 +118,7 @@ exports.minify = function(files, options) {
if (typeof options.inSourceMap == "string") {
inMap = JSON.parse(fs.readFileSync(options.inSourceMap, "utf8"));
}
- if (options.outSourceMap) {
+ if (options.outSourceMap || options.sourceMapInline) {
output.source_map = UglifyJS.SourceMap({
file: options.outSourceMap,
orig: inMap,
@@ -138,16 +139,19 @@ exports.minify = function(files, options) {
var stream = UglifyJS.OutputStream(output);
toplevel.print(stream);
- var mappingUrlPrefix = "\n//# sourceMappingURL=";
- if (options.outSourceMap && typeof options.outSourceMap === "string" && options.sourceMapUrl !== false) {
- stream += mappingUrlPrefix + (typeof options.sourceMapUrl === "string" ? options.sourceMapUrl : options.outSourceMap);
- }
var source_map = output.source_map;
if (source_map) {
source_map = source_map + "";
}
+ var mappingUrlPrefix = "\n//# sourceMappingURL=";
+ if (options.sourceMapInline) {
+ stream += mappingUrlPrefix + "data:application/json;charset=utf-8;base64," + new Buffer(source_map).toString("base64");
+ } else if (options.outSourceMap && typeof options.outSourceMap === "string" && options.sourceMapUrl !== false) {
+ stream += mappingUrlPrefix + (typeof options.sourceMapUrl === "string" ? options.sourceMapUrl : options.outSourceMap);
+ }
+
return {
code : stream + "",
map : source_map