overhaul dev/prod script loading

This commit is contained in:
BuckarooBanzay 2022-02-05 08:05:55 +01:00
parent de2a105243
commit 4e44790ca2
2 changed files with 9 additions and 18 deletions

View File

@ -1,7 +1,6 @@
<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data:; connect-src 'self'; style-src 'self'; script-src 'self';report-uri /csp-reports">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="theme-color" content="#000">
@ -28,6 +27,14 @@
<script src="js/lib/moment.min.js"></script>
<!-- bootstrap script -->
<script src="js/bootstrap.js"></script>
<script>
function dev_fallback(){
var s = document.createElement("script");
s.setAttribute("src", "js/main.js");
s.setAttribute("type", "module");
document.body.appendChild(s);
};
</script>
<script src="js/bundle.js" onerror="dev_fallback()"></script>
</body>
</html>

View File

@ -1,16 +0,0 @@
(function(){
var s = document.createElement("script");
if (location.host === "127.0.0.1:8080") {
//dev
s.setAttribute("src", "js/main.js");
s.setAttribute("type", "module");
} else {
//prod
s.setAttribute("src", "js/bundle.js");
}
document.body.appendChild(s);
})();