mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-15 12:02:54 +01:00
filter files before minify, removed unused ctime
This commit is contained in:
@@ -15,6 +15,10 @@ var uglifyjs = require('uglify-js'),
|
||||
Minifier.js.minify = function (scripts, minify, callback) {
|
||||
var options = {};
|
||||
|
||||
scripts = scripts.filter(function(file) {
|
||||
return fs.existsSync(file);
|
||||
});
|
||||
|
||||
if (!minify) {
|
||||
options.sourceMapURL = '/nodebb.min.js.map';
|
||||
options.outSourceMap = 'nodebb.min.js.map';
|
||||
@@ -32,7 +36,9 @@ Minifier.js.minify = function (scripts, minify, callback) {
|
||||
} catch(err) {
|
||||
process.send({
|
||||
action: 'error',
|
||||
error: err
|
||||
error: {
|
||||
message: err.message
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
42
src/meta.js
42
src/meta.js
@@ -281,32 +281,31 @@ var fs = require('fs'),
|
||||
},
|
||||
prepare: function (callback) {
|
||||
plugins.fireHook('filter:scripts.get', this.scripts, function(err, scripts) {
|
||||
var ctime,
|
||||
jsPaths = scripts.map(function (jsPath) {
|
||||
jsPath = path.normalize(jsPath);
|
||||
var jsPaths = scripts.map(function (jsPath) {
|
||||
jsPath = path.normalize(jsPath);
|
||||
|
||||
if (jsPath.substring(0, 7) === 'plugins') {
|
||||
var matches = _.map(plugins.staticDirs, function(realPath, mappedPath) {
|
||||
if (jsPath.match(mappedPath)) {
|
||||
return mappedPath;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}).filter(function(a) { return a; });
|
||||
|
||||
if (matches.length) {
|
||||
var relPath = jsPath.slice(('plugins/' + matches[0]).length),
|
||||
pluginId = matches[0].split(path.sep)[0];
|
||||
|
||||
return plugins.staticDirs[matches[0]] + relPath;
|
||||
if (jsPath.substring(0, 7) === 'plugins') {
|
||||
var matches = _.map(plugins.staticDirs, function(realPath, mappedPath) {
|
||||
if (jsPath.match(mappedPath)) {
|
||||
return mappedPath;
|
||||
} else {
|
||||
winston.warn('[meta.scripts.get] Could not resolve mapped path: ' + jsPath + '. Are you sure it is defined by a plugin?');
|
||||
return null;
|
||||
}
|
||||
}).filter(function(a) { return a; });
|
||||
|
||||
if (matches.length) {
|
||||
var relPath = jsPath.slice(('plugins/' + matches[0]).length),
|
||||
pluginId = matches[0].split(path.sep)[0];
|
||||
|
||||
return plugins.staticDirs[matches[0]] + relPath;
|
||||
} else {
|
||||
return path.join(__dirname, '..', '/public', jsPath);
|
||||
winston.warn('[meta.scripts.get] Could not resolve mapped path: ' + jsPath + '. Are you sure it is defined by a plugin?');
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return path.join(__dirname, '..', '/public', jsPath);
|
||||
}
|
||||
});
|
||||
|
||||
Meta.js.scripts = jsPaths.filter(function(path) {
|
||||
return path !== null;
|
||||
@@ -332,8 +331,7 @@ var fs = require('fs'),
|
||||
|
||||
emitter.emit('meta:js.compiled');
|
||||
} else {
|
||||
winston.error('[meta/js] Could not compile client-side scripts!');
|
||||
winston.error('[meta/js] ' + payload.error.message);
|
||||
winston.error('[meta/js] Could not compile client-side scripts! ' + payload.error.message);
|
||||
minifier.kill();
|
||||
process.exit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user