blob: 438d198f54396bf217a196015eb62cab255a4073 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#! /usr/bin/env node
var sys = require("util");
var fs = require("fs");
var UglifyJS = require("../tools/node");
var files = process.argv.slice(2);
var map = UglifyJS.SourceMap();
var output = UglifyJS.OutputStream({
beautify : false,
source_map : map
});
function do_file(file) {
var code = fs.readFileSync(file, "utf8");
// parse
var ast = UglifyJS.parse(code);
// mangle
ast.figure_out_scope();
ast.mangle_names();
// compress
var compressor = UglifyJS.Compressor();
ast.squeeze(compressor);
// generate source into the output stream
// first reset the current file name in the source map.
UglifyJS.time_it("generate", function(){
map.set_source(file);
ast.print(output);
});
};
files.forEach(do_file);
fs.writeFileSync("/tmp/source-map.json", map, "utf8");
sys.print(output);
|