aboutsummaryrefslogtreecommitdiff
path: root/bin/uglifyjs
diff options
context:
space:
mode:
authorpengzhenqing <pengzhenqing@sensetime.com>2016-10-09 14:15:25 +0800
committerRichard van Velzen <rvanvelzen1@gmail.com>2016-10-23 21:21:39 +0200
commite51c6ba38014fc73a4804a69c556d96f777bc0b3 (patch)
tree6313e745cf0d054514fd4ac201e23885576c1419 /bin/uglifyjs
parent6389e52305f0d2e75a7bc6f8703c8d163d04cb99 (diff)
downloadtracifyjs-e51c6ba38014fc73a4804a69c556d96f777bc0b3.tar.gz
tracifyjs-e51c6ba38014fc73a4804a69c556d96f777bc0b3.zip
Add an option for writing inline source map
Diffstat (limited to 'bin/uglifyjs')
-rwxr-xr-xbin/uglifyjs23
1 files changed, 15 insertions, 8 deletions
diff --git a/bin/uglifyjs b/bin/uglifyjs
index da9e0f10..76438961 100755
--- a/bin/uglifyjs
+++ b/bin/uglifyjs
@@ -23,6 +23,7 @@ mangling you need to use `-c` and `-m`.\
.describe("source-map", "Specify an output file where to generate source map.")
.describe("source-map-root", "The path to the original source to be included in the source map.")
.describe("source-map-url", "The path to the source map to be added in //# sourceMappingURL. Defaults to the value passed with --source-map.")
+ .describe("source-map-inline", "Write base64-encoded source map to the end of js output. Disabled by default")
.describe("source-map-include-sources", "Pass this flag if you want to include the content of source files in the source map as sourcesContent property.")
.describe("in-source-map", "Input source map, useful if you're compressing JS that was generated from some other original code.")
.describe("screw-ie8", "Do not support Internet Explorer 6-8 quirks. This flag is enabled by default.")
@@ -113,6 +114,7 @@ You need to pass an argument to this option to specify the name that your module
.array("pure-funcs")
.boolean("expr")
+ .boolean("source-map-inline")
.boolean("source-map-include-sources")
.boolean("screw-ie8")
.boolean("support-ie8")
@@ -309,7 +311,7 @@ var TOPLEVEL = null;
var P_RELATIVE = ARGS.p && ARGS.p == "relative";
var SOURCES_CONTENT = {};
-var SOURCE_MAP = ARGS.source_map ? UglifyJS.SourceMap({
+var SOURCE_MAP = (ARGS.source_map || ARGS.source_map_inline) ? UglifyJS.SourceMap({
file: P_RELATIVE ? path.relative(path.dirname(ARGS.source_map), OUTPUT_FILE) : OUTPUT_FILE,
root: ARGS.source_map_root,
orig: ORIG_MAP,
@@ -474,13 +476,18 @@ async.eachLimit(files, 1, function (file, cb) {
output = output.get();
if (SOURCE_MAP) {
- fs.writeFileSync(ARGS.source_map, SOURCE_MAP, "utf8");
- var source_map_url = ARGS.source_map_url || (
- P_RELATIVE
- ? path.relative(path.dirname(OUTPUT_FILE), ARGS.source_map)
- : ARGS.source_map
- );
- output += "\n//# sourceMappingURL=" + source_map_url;
+ if (ARGS.source_map_inline) {
+ var base64_string = new Buffer(SOURCE_MAP.toString()).toString('base64');
+ output += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + base64_string;
+ } else {
+ fs.writeFileSync(ARGS.source_map, SOURCE_MAP, "utf8");
+ var source_map_url = ARGS.source_map_url || (
+ P_RELATIVE
+ ? path.relative(path.dirname(OUTPUT_FILE), ARGS.source_map)
+ : ARGS.source_map
+ );
+ output += "\n//# sourceMappingURL=" + source_map_url;
+ }
}
if (OUTPUT_FILE) {