|
|
@ -10,31 +10,31 @@ var uglifyjs = require('uglify-js'),
|
|
|
|
|
|
|
|
|
|
|
|
/* Javascript */
|
|
|
|
/* Javascript */
|
|
|
|
Minifier.js.minify = function (scripts, callback) {
|
|
|
|
Minifier.js.minify = function (scripts, callback) {
|
|
|
|
// winston.info('[meta/js] Minifying client-side libraries...');
|
|
|
|
try {
|
|
|
|
var minified = uglifyjs.minify(scripts);
|
|
|
|
var minified = uglifyjs.minify(scripts);
|
|
|
|
|
|
|
|
|
|
|
|
callback(minified.code);
|
|
|
|
callback(minified.code);
|
|
|
|
|
|
|
|
} catch(err) {
|
|
|
|
// winston.info('[meta/js] Done.');
|
|
|
|
process.send({
|
|
|
|
|
|
|
|
action: 'error',
|
|
|
|
|
|
|
|
error: err
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Minifier.js.concatenate = function(scripts, callback) {
|
|
|
|
Minifier.js.concatenate = function(scripts, callback) {
|
|
|
|
// winston.info('[meta/js] Concatenating client-side libraries into one file...');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async.map(scripts, function(path, next) {
|
|
|
|
async.map(scripts, function(path, next) {
|
|
|
|
fs.readFile(path, { encoding: 'utf-8' }, next);
|
|
|
|
fs.readFile(path, { encoding: 'utf-8' }, next);
|
|
|
|
}, function(err, contents) {
|
|
|
|
}, function(err, contents) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
// winston.error('[meta/js] Could not minify javascript! Error: ' + err.message);
|
|
|
|
process.send({
|
|
|
|
console.log('ERROR');
|
|
|
|
action: 'error',
|
|
|
|
process.exit();
|
|
|
|
error: err
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
callback(contents.reduce(function(output, src) {
|
|
|
|
callback(contents.reduce(function(output, src) {
|
|
|
|
return output.length ? output + ';\n' + src : src;
|
|
|
|
return output.length ? output + ';\n' + src : src;
|
|
|
|
}, ''));
|
|
|
|
}, ''));
|
|
|
|
|
|
|
|
}
|
|
|
|
// winston.info('[meta/js] Done.');
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|