UI for Zipcoin Blue

only-dev-server.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. /*globals __webpack_hash__ */
  6. if(module.hot) {
  7. var lastHash;
  8. var upToDate = function upToDate() {
  9. return lastHash.indexOf(__webpack_hash__) >= 0;
  10. };
  11. var log = require("./log");
  12. var check = function check() {
  13. module.hot.check().then(function(updatedModules) {
  14. if(!updatedModules) {
  15. log("warning", "[HMR] Cannot find update. Need to do a full reload!");
  16. log("warning", "[HMR] (Probably because of restarting the webpack-dev-server)");
  17. return;
  18. }
  19. return module.hot.apply({
  20. ignoreUnaccepted: true,
  21. ignoreDeclined: true,
  22. ignoreErrored: true,
  23. onUnaccepted: function(data) {
  24. log("warning", "Ignored an update to unaccepted module " + data.chain.join(" -> "));
  25. },
  26. onDeclined: function(data) {
  27. log("warning", "Ignored an update to declined module " + data.chain.join(" -> "));
  28. },
  29. onErrored: function(data) {
  30. log("error", data.error);
  31. log("warning", "Ignored an error while updating module " + data.moduleId + " (" + data.type + ")");
  32. }
  33. }).then(function(renewedModules) {
  34. if(!upToDate()) {
  35. check();
  36. }
  37. require("./log-apply-result")(updatedModules, renewedModules);
  38. if(upToDate()) {
  39. log("info", "[HMR] App is up to date.");
  40. }
  41. });
  42. }).catch(function(err) {
  43. var status = module.hot.status();
  44. if(["abort", "fail"].indexOf(status) >= 0) {
  45. log("warning", "[HMR] Cannot check for update. Need to do a full reload!");
  46. log("warning", "[HMR] " + err.stack || err.message);
  47. } else {
  48. log("warning", "[HMR] Update check failed: " + err.stack || err.message);
  49. }
  50. });
  51. };
  52. var hotEmitter = require("./emitter");
  53. hotEmitter.on("webpackHotUpdate", function(currentHash) {
  54. lastHash = currentHash;
  55. if(!upToDate()) {
  56. var status = module.hot.status();
  57. if(status === "idle") {
  58. log("info", "[HMR] Checking for updates on the server...");
  59. check();
  60. } else if(["abort", "fail"].indexOf(status) >= 0) {
  61. log("warning", "[HMR] Cannot apply update as a previous update " + status + "ed. Need to do a full reload!");
  62. }
  63. }
  64. });
  65. log("info", "[HMR] Waiting for update signal from WDS...");
  66. } else {
  67. throw new Error("[HMR] Hot Module Replacement is disabled.");
  68. }