Browse Source

make_client uses Uglify ES

pull/126/head
Lal'C Mellk Mal 2 years ago
parent
commit
cf8baff73e
2 changed files with 16 additions and 20 deletions
  1. +14
    -20
      make_client.js
  2. +2
    -0
      package.json

+ 14
- 20
make_client.js View File

@@ -1,9 +1,10 @@
var async = require('async'),
child_process = require('child_process'),
config = require('./config'),
fs = require('fs'),
imagerConfig = require('./imager/config'),
reportConfig = require('./report/config'),
fs = require('fs'),
streamBuffers = require('stream-buffers'),
util = require('util');

function make_client(inputs, out, cb) {
@@ -104,29 +105,22 @@ fs.readFile(file, 'UTF-8', function (err, fullFile) {
exports.make_client = make_client;

function make_minified(files, out, cb) {

// would be nice if uglify streamed...
require('tmp').file({
postfix: '.gen.js',
},
function (err, tmp, fd) {
if (err) return cb(err);
var out = fs.createWriteStream(null, {fd: fd});
out.once('error', cb);
make_client(files, out, function (err) {
if (err)
return cb(err);
out.end(function () {
minify(tmp);
});
});
var buf = new streamBuffers.WritableStreamBuffer();
buf.once('error', cb);
make_client(files, buf, function (err) {
if (err)
return cb(err);
var src = buf.getContentsAsString('utf-8');
if (!src || !src.length)
return cb('make_minified: no client JS was generated');
minify(src);
});

function minify(file) {
var UglifyJS = require('uglify-js');
function minify(src) {
var UglifyJS = require('uglify-es');
var ugly;
try {
ugly = UglifyJS.minify(file, {
ugly = UglifyJS.minify(src, {
mangle: false,
});
}


+ 2
- 0
package.json View File

@@ -26,7 +26,9 @@
"redis": "2.6.3",
"request": "2.79",
"sockjs": "0.3.18",
"stream-buffers": "^3.0.1",
"tmp": "0.0.31",
"uglify-es": "^3.3.9",
"uglify-js": "2.7.5",
"winston": "2.3.0"
},


Loading…
Cancel
Save