fix for minification of plugins static directories

v1.18.x
psychobunny 11 years ago
parent c8e423e9cf
commit 5db27a835f

@ -207,9 +207,19 @@ var fs = require('fs'),
plugins.fireHook('filter:scripts.get', this.scripts, function(err, scripts) { plugins.fireHook('filter:scripts.get', this.scripts, function(err, scripts) {
var mtime, var mtime,
jsPaths = scripts.map(function (jsPath) { jsPaths = scripts.map(function (jsPath) {
return path.join(__dirname, '..', '/public', jsPath); if (jsPath.substring(0, 7) === 'plugins') {
var paths = jsPath.split('/'),
pluginID = paths[1];
jsPath = jsPath.replace(path.join('plugins', pluginID), '');
return path.join(plugins.staticDirs[pluginID], jsPath);
} else {
return path.join(__dirname, '..', '/public', jsPath);
}
}); });
Meta.js.scripts = jsPaths;
if (process.env.NODE_ENV !== 'development') { if (process.env.NODE_ENV !== 'development') {
async.parallel({ async.parallel({
mtime: function (next) { mtime: function (next) {
@ -226,7 +236,7 @@ var fs = require('fs'),
}, },
minFile: function (next) { minFile: function (next) {
if (!fs.existsSync(Meta.js.minFile)) { if (!fs.existsSync(Meta.js.minFile)) {
if (process.env.NODE_ENV === 'development') winston.warn('No minified client-side library found'); winston.warn('No minified client-side library found');
return next(null, 0); return next(null, 0);
} }
@ -236,12 +246,12 @@ var fs = require('fs'),
} }
}, function (err, results) { }, function (err, results) {
if (results.minFile > results.mtime) { if (results.minFile > results.mtime) {
if (process.env.NODE_ENV === 'development') winston.info('No changes to client-side libraries -- skipping minification'); winston.info('No changes to client-side libraries -- skipping minification');
callback(null, [path.relative(path.join(__dirname, '../public'), Meta.js.minFile)]); callback(null, [path.relative(path.join(__dirname, '../public'), Meta.js.minFile)]);
} else { } else {
Meta.js.minify(function () { Meta.js.minify(function () {
callback(null, [ callback(null, [
path.relative(path.join(__dirname, '../public'), Meta.js.minFile) + (meta.config['cache-buster'] ? '?v=' + meta.config['cache-buster'] : '') path.relative(path.join(__dirname, '../public'), Meta.js.minFile) + (meta.config['cache-buster'] ? '?vs=' + meta.config['cache-buster'] : '')
]); ]);
}); });
} }
@ -258,9 +268,7 @@ var fs = require('fs'),
}, },
minify: function (callback) { minify: function (callback) {
var uglifyjs = require('uglify-js'), var uglifyjs = require('uglify-js'),
jsPaths = this.scripts.map(function (jsPath) { jsPaths = this.scripts,
return path.join(__dirname, '..', '/public', jsPath);
}),
minified; minified;
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {

Loading…
Cancel
Save