colouring-montreal/app/src/index.js
2018-09-09 22:22:44 +01:00

27 lines
576 B
JavaScript

import app from './server';
import http from 'http';
const server = http.createServer(app);
let currentApp = app;
server.listen(process.env.PORT || 3000, error => {
if (error) {
console.log(error);
}
console.log('🚀 started');
});
if (module.hot) {
console.log('✅ Server-side HMR Enabled!');
module.hot.accept('./server', () => {
console.log('🔁 HMR Reloading x`./server`...');
server.removeListener('request', currentApp);
const newApp = require('./server').default;
server.on('request', newApp);
currentApp = newApp;
});
}