Skip to content

Instantly share code, notes, and snippets.

@jkinkead
Created October 19, 2018 00:01
Show Gist options
  • Save jkinkead/3301e0d2ef18c5339f07e78b50b8d043 to your computer and use it in GitHub Desktop.
Save jkinkead/3301e0d2ef18c5339f07e78b50b8d043 to your computer and use it in GitHub Desktop.
Hot reload configuration
// Save the initial app so we can remove it from the server when
// there are Webpack Hot Module Reload updates.
let currentApp = initialApp
if (module.hot) {
module.hot.accept('../index.js', () => {
// Create a new Express app with the updated Cloud Function
// handlers.
const newApp = setUpApp(require('../index.js'))
// Remove the old Express app.
server.removeListener('request', currentApp)
// Register the new app with the server.
server.on('request', newApp)
// Save the current app so we can remove it when there are
// updates.
currentApp = newApp
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment