mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
propagating hash to all workers on css compilation
This commit is contained in:
@@ -81,7 +81,8 @@ Loader.addClusterEvents = function(callback) {
|
|||||||
worker.send({
|
worker.send({
|
||||||
action: 'css-propagate',
|
action: 'css-propagate',
|
||||||
cache: Loader.css.cache,
|
cache: Loader.css.cache,
|
||||||
acpCache: Loader.css.acpCache
|
acpCache: Loader.css.acpCache,
|
||||||
|
hash: Loader.css.hash
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +121,7 @@ Loader.addClusterEvents = function(callback) {
|
|||||||
case 'css-propagate':
|
case 'css-propagate':
|
||||||
Loader.css.cache = message.cache;
|
Loader.css.cache = message.cache;
|
||||||
Loader.css.acpCache = message.acpCache;
|
Loader.css.acpCache = message.acpCache;
|
||||||
|
Loader.css.hash = message.hash;
|
||||||
|
|
||||||
otherWorkers = Object.keys(cluster.workers).filter(function(worker_id) {
|
otherWorkers = Object.keys(cluster.workers).filter(function(worker_id) {
|
||||||
return parseInt(worker_id, 10) !== parseInt(worker.id, 10);
|
return parseInt(worker_id, 10) !== parseInt(worker.id, 10);
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ module.exports = function(Meta) {
|
|||||||
process.send({
|
process.send({
|
||||||
action: 'css-propagate',
|
action: 'css-propagate',
|
||||||
cache: minified[0],
|
cache: minified[0],
|
||||||
acpCache: minified[1]
|
acpCache: minified[1],
|
||||||
|
hash: Meta.css.hash
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,11 +140,14 @@ module.exports = function(Meta) {
|
|||||||
|
|
||||||
Meta.css[destination] = lessOutput.css;
|
Meta.css[destination] = lessOutput.css;
|
||||||
|
|
||||||
|
if (destination === 'cache') {
|
||||||
// Calculate css buster
|
// Calculate css buster
|
||||||
var hasher = crypto.createHash('md5');
|
var hasher = crypto.createHash('md5');
|
||||||
|
|
||||||
hasher.update(lessOutput.css, 'utf-8');
|
hasher.update(lessOutput.css, 'utf-8');
|
||||||
Meta.css.hash = hasher.digest('hex').slice(0, 8);
|
Meta.css.hash = hasher.digest('hex').slice(0, 8);
|
||||||
|
console.log('the hash is now', Meta.css.hash);
|
||||||
|
}
|
||||||
|
|
||||||
// Save the compiled CSS in public/ so things like nginx can serve it
|
// Save the compiled CSS in public/ so things like nginx can serve it
|
||||||
if (!cluster.isWorker || process.env.cluster_setup === 'true') {
|
if (!cluster.isWorker || process.env.cluster_setup === 'true') {
|
||||||
|
|||||||
Reference in New Issue
Block a user