mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: Add live reload functionality with Grunt watch and Socket.IO (#13489)
- Added livereload event to Grunt watch tasks for instant browser refresh - Integrated Socket.IO WebSocket communication for real-time updates - Enhanced development workflow with immediate file change detection - Improved developer experience with automatic browser reload on file changes Changes: - Gruntfile.js: Send livereload message when files change - src/start.js: Handle livereload events and broadcast via Socket.IO
This commit is contained in:
@@ -174,6 +174,8 @@ module.exports = function (grunt) {
|
|||||||
}
|
}
|
||||||
if (worker) {
|
if (worker) {
|
||||||
worker.send({ compiling: compiling });
|
worker.send({ compiling: compiling });
|
||||||
|
// Send livereload event via Socket.IO for instant browser refresh
|
||||||
|
worker.send({ livereload: true });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -115,6 +115,13 @@ function addProcessHandlers() {
|
|||||||
const translator = require('./translator');
|
const translator = require('./translator');
|
||||||
translator.flush();
|
translator.flush();
|
||||||
}
|
}
|
||||||
|
} else if (msg && msg.livereload) {
|
||||||
|
// Send livereload event to all connected clients via Socket.IO
|
||||||
|
const websockets = require('./socket.io');
|
||||||
|
if (websockets.server) {
|
||||||
|
websockets.server.emit('event:livereload');
|
||||||
|
winston.info('[livereload] Sent reload event to all clients');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user