Last active
May 10, 2016 00:40
-
-
Save maheshsenni/7fa7eeab61b390b0958f287ac72ed332 to your computer and use it in GitHub Desktop.
Step 2b - Creating a module bundler with Hot Module Replacement
This file contains 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
/* This file is included in the page running the app */ | |
(function() { | |
// create an instance of Socket.IO for listening | |
// to websocket messages | |
var socket = io(); | |
// listen for 'file-change' message | |
socket.on('file-change', function(msg) { | |
console.log('File changed: ' + msg.id); | |
// reload the browser to get the latest changes | |
// we will replace this later to "hot update" | |
// only the changed modules | |
window.location.reload(); | |
}); | |
})(); |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>HMR sample</title> | |
</head> | |
<body> | |
<h2>Counter</h2> | |
<h2 id="counter"></h2> | |
<!-- Provided by Socket.IO for listening to websocket messages --> | |
<script src="/socket.io/socket.io.js"></script> | |
<!-- Code which performs some action after a websocket message is received --> | |
<script src="hmr.js"></script> | |
<!-- Counter application code --> | |
<script src="bundle.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment