Created
October 19, 2018 00:01
-
-
Save jkinkead/3301e0d2ef18c5339f07e78b50b8d043 to your computer and use it in GitHub Desktop.
Hot reload configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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