Skip to content

Instantly share code, notes, and snippets.

@mhaagens
Created March 7, 2017 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhaagens/99c6880fa219fd3fef9cf898eacd3bdb to your computer and use it in GitHub Desktop.
Save mhaagens/99c6880fa219fd3fef9cf898eacd3bdb to your computer and use it in GitHub Desktop.
Koa HMR
import http from 'http';
import app from './server';
const port = 3000;
const server = http.createServer(app.callback()).listen(3000);
if (module.hot) {
module.hot.accept('./server', () => {
server.removeAllListeners('request', server);
server.on('request', app.callback())
});
}
console.log(`Server running on: http://localhost: ${port}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment