mirror of
https://github.com/aleleba/create-react-ssr.git
synced 2025-07-26 22:48:33 -06:00
PR-687356: Updating packages and adding support to HMR to server also.
This commit is contained in:
7
src/@types/index.d.ts
vendored
7
src/@types/index.d.ts
vendored
@ -2,3 +2,10 @@ declare module '*.svg' {
|
||||
const content: any;
|
||||
export default content;
|
||||
}
|
||||
|
||||
declare const module: {
|
||||
hot?: {
|
||||
accept(dep?: string, callback?: () => void): void;
|
||||
dispose(callback: () => void): void;
|
||||
};
|
||||
};
|
||||
|
@ -131,6 +131,19 @@ const renderApp = (req, res, next) => {
|
||||
app
|
||||
.get('/{*splat}', renderApp);
|
||||
|
||||
app.listen(PORT, () => {
|
||||
const server = app.listen(PORT, () => {
|
||||
console.log(`Server running on port ${PORT}`);
|
||||
});
|
||||
|
||||
// --- HMR Support ---
|
||||
if (module.hot) {
|
||||
module.hot.accept();
|
||||
module.hot.dispose(() => {
|
||||
console.log('🔁 [HMR] Disposing backend module...');
|
||||
if (server) {
|
||||
server.close(() => {
|
||||
console.log('🛑 Server closed due to HMR');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user