mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-05 12:01:17 +01:00
concatenating the client scripts, instead of compressing, in development mode
This commit is contained in:
25
src/meta.js
25
src/meta.js
@@ -299,21 +299,24 @@ var fs = require('fs'),
|
||||
this.cache = minified.code;
|
||||
callback();
|
||||
},
|
||||
compress: function(callback) {
|
||||
var uglifyjs = require('uglify-js'),
|
||||
jsPaths = this.scripts,
|
||||
compressed;
|
||||
|
||||
concatenate: function(callback) {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
winston.info('Compressing client-side libraries into one file');
|
||||
winston.info('Concatenating client-side libraries into one file');
|
||||
}
|
||||
|
||||
minified = uglifyjs.minify(jsPaths, {
|
||||
mangle: false,
|
||||
compress: false
|
||||
async.map(this.scripts, function(path, next) {
|
||||
fs.readFile(path, { encoding: 'utf-8' }, next);
|
||||
}, function(err, contents) {
|
||||
if (err) {
|
||||
winston.error('[meta.js.concatenate] Could not minify javascript! Error: ' + err.message);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
Meta.js.cache = contents.reduce(function(output, src) {
|
||||
return output.length ? output + ';\n' + src : src;
|
||||
}, '');
|
||||
callback();
|
||||
});
|
||||
this.cache = minified.code;
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ var path = require('path'),
|
||||
});
|
||||
} else {
|
||||
// Compress only
|
||||
meta.js.compress(function() {
|
||||
meta.js.concatenate(function() {
|
||||
sendCached();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user