mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-05 05:25:49 +01:00
closes #5859
This commit is contained in:
@@ -42,7 +42,10 @@ web.install = function (port) {
|
|||||||
extended: true,
|
extended: true,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
async.parallel([compileLess, compileJS], function () {
|
async.parallel([compileLess, compileJS], function (err) {
|
||||||
|
if (err) {
|
||||||
|
winston.error(err);
|
||||||
|
}
|
||||||
setupRoutes();
|
setupRoutes();
|
||||||
launchExpress(port);
|
launchExpress(port);
|
||||||
});
|
});
|
||||||
@@ -152,13 +155,32 @@ function compileLess(callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function compileJS(callback) {
|
function compileJS(callback) {
|
||||||
var scriptPath = path.join(__dirname, '..');
|
var code = '';
|
||||||
var result = uglify.minify(scripts.map(function (script) {
|
async.eachSeries(scripts, function (srcPath, next) {
|
||||||
return path.join(scriptPath, script);
|
fs.readFile(path.join(__dirname, '..', srcPath), function (err, buffer) {
|
||||||
}));
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
code += buffer.toString();
|
||||||
fs.writeFile(path.join(__dirname, '../public/installer.min.js'), result.code, callback);
|
next();
|
||||||
|
});
|
||||||
|
}, function (err) {
|
||||||
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
var minified = uglify.minify(code, {
|
||||||
|
compress: false,
|
||||||
|
});
|
||||||
|
if (!minified.code) {
|
||||||
|
return callback(new Error('[[error:failed-to-minify]]'));
|
||||||
|
}
|
||||||
|
fs.writeFile(path.join(__dirname, '../public/installer.min.js'), minified.code, callback);
|
||||||
|
} catch (e) {
|
||||||
|
callback(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = web;
|
module.exports = web;
|
||||||
|
|||||||
Reference in New Issue
Block a user