From 9e16b9a575efa51f608f8096f1a8c0b390faece8 Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Tue, 17 Jan 2012 01:22:23 -0800 Subject: [PATCH] Always use the JS assets processed by Minify. This allows the preprocessing that will restrict scope of files to be done once in Minify. --- node/utils/Minify.js | 13 ++++++++++++- static/js/ace.js | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/node/utils/Minify.js b/node/utils/Minify.js index 1a214fb9..d3c8831a 100644 --- a/node/utils/Minify.js +++ b/node/utils/Minify.js @@ -52,10 +52,21 @@ exports.minifyJS = function(req, res, next) var jsFiles = undefined; if (Object.prototype.hasOwnProperty.call(tar, jsFilename)) { jsFiles = tar[jsFilename]; + _handle(req, res, jsFilename, jsFiles) } else { - return next(); + // Not in tar list, but try anyways, if it fails, pass to `next`. + jsFiles = [jsFilename]; + fs.stat(JS_DIR + jsFilename, function (error, stats) { + if (error || !stats.isFile()) { + next(); + } else { + _handle(req, res, jsFilename, jsFiles); + } + }); } +} +function _handle(req, res, jsFilename, jsFiles) { res.header("Content-Type","text/javascript"); //minifying is enabled diff --git a/static/js/ace.js b/static/js/ace.js index 3f52d315..4735aaae 100644 --- a/static/js/ace.js +++ b/static/js/ace.js @@ -230,6 +230,7 @@ function Ace2Editor() } for (var i = 0, ii = remoteFiles.length; i < ii; i++) { var file = remoteFiles[i]; + file = file.replace(/^\.\.\/static\/js\//, '../minified/'); buffer.push('