This repository has been archived by the owner on Oct 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: auto restart dev container when hmr fails
- Loading branch information
Showing
2 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
MIT License http://www.opensource.org/licenses/mit-license.php | ||
Author Tobias Koppers @sokra | ||
Version 3e03edc on Jul 9, 2018 | ||
*/ | ||
/*globals __resourceQuery */ | ||
if (module.hot) { | ||
var hotPollInterval = +__resourceQuery.substr(1) || 10 * 60 * 1000; | ||
var log = require("webpack/hot/log"); | ||
|
||
var checkForUpdate = function checkForUpdate(fromUpdate) { | ||
if (module.hot.status() === "idle") { | ||
module.hot | ||
.check(true) | ||
.then(function(updatedModules) { | ||
if (!updatedModules) { | ||
if (fromUpdate) log("info", "[HMR] Update applied."); | ||
return; | ||
} | ||
require("webpack/hot/log-apply-result")(updatedModules, updatedModules); | ||
checkForUpdate(true); | ||
}) | ||
.catch(function(err) { | ||
var status = module.hot.status(); | ||
if (["abort", "fail"].indexOf(status) >= 0) { | ||
log("warning", "[HMR] Cannot apply update."); | ||
log("warning", "[HMR] " + (err.stack || err.message)); | ||
log("warning", "[HMR] You need to restart the application!"); | ||
} else { | ||
log( | ||
"warning", | ||
"[HMR] Update failed: " + (err.stack || err.message) | ||
); | ||
} | ||
// <udk patch> | ||
if (process.send) { | ||
log("warning", "[HMR] udk auto restart the application..."); | ||
process.send({ action: 'run' }); | ||
} | ||
// </udk patch> | ||
}); | ||
} | ||
}; | ||
setInterval(checkForUpdate, hotPollInterval); | ||
} else { | ||
throw new Error("[HMR] Hot Module Replacement is disabled."); | ||
} |
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