Skip to content

Instantly share code, notes, and snippets.

@Uzwername
Last active August 23, 2020 17:33
Show Gist options
  • Save Uzwername/ee989c2a914da022b8ed8006206096da to your computer and use it in GitHub Desktop.
Save Uzwername/ee989c2a914da022b8ed8006206096da to your computer and use it in GitHub Desktop.
HtmlWebpackPlugin - First attempt
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Handling script loading errors with HtmlWebpackPlugin</title>
</head>
<body>
<h1 id="content"></h1>
<script>
(function(){
function showErrorPage() {
// Doesn't matter for now
}
var appScript = document.querySelector('script[src^="bundle"]');
appScript.addEventListener('error', showErrorPage);
})();
</script>
<!--
HTMLWebpackPlugin will insert bundled script here on build.
It will look something like this:
<script src="bundle.foo12.js"></script>
-->
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment