added new --from-file flag that will load js/css from the precompiled file instead of recompiling it on startup

This commit is contained in:
Julian Lam
2014-10-21 15:25:16 -04:00
parent ebfb953069
commit 1a90de7dd6
7 changed files with 100 additions and 39 deletions

View File

@@ -99,6 +99,30 @@ module.exports = function(Meta) {
});
};
Meta.css.getFromFile = function(callback) {
var cachePath = path.join(__dirname, '../../public/stylesheet.css'),
acpCachePath = path.join(__dirname, '../../public/admin.css');
fs.exists(cachePath, function(exists) {
if (exists) {
if (!cluster.isWorker || process.env.cluster_setup === 'true') {
winston.info('[meta/css] (Experimental) Reading stylesheets from file');
async.map([cachePath, acpCachePath], fs.readFile, function(err, files) {
Meta.css.cache = files[0];
Meta.css.acpCache = files[1];
emitter.emit('meta:css.compiled');
callback();
});
} else {
callback();
}
} else {
winston.warn('[meta/css] (Experimental) No stylesheets found on disk, re-minifying');
Meta.css.minify.apply(Meta.css, arguments);
}
});
};
function minify(source, paths, destination, callback) {
var parser = new (less.Parser)({
paths: paths