Skip to content

Commit

Permalink
chore: Remove prebuild command
Browse files Browse the repository at this point in the history
Prebuild was messing up the dev server, but I do not know why
  • Loading branch information
johnedvard committed Aug 17, 2022
1 parent fc51793 commit 0a1f246
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"source": "src/index.html",
"scripts": {
"start": "parcel serve",
"prebuild": "rm -rf dist",
"build": "parcel build src/index.html"
},
"author": "johnedvard",
Expand Down
7 changes: 1 addition & 6 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@
<meta charset="utf-8" />
<title>Skeleton rope</title>
<link rel="stylesheet" href="styles.css" />
<!-- TODO (johnedvard) Load near API through code instead -->
<script
type="module"
src="https://js13kgames.com/src/near-api-js.js"
></script>
<script type="module" src="index.js"></script>
</head>
<body>
<button id="loginout"></button>
<button id="loginout">Loading....</button>
<canvas width="800px" height="800px"></canvas>
</body>
</html>
20 changes: 17 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,23 @@ const init = () => {
};

const initNear = () => {
const nearConnection = new NearConnection();
nearConnection.initContract().then((res) => {
initLoginLogout(nearConnection);
loadNearApi().then(() => {
const nearConnection = new NearConnection();
nearConnection.initContract().then(() => {
initLoginLogout(nearConnection);
});
});
};

const loadNearApi = () => {
return new Promise((resolve) => {
if (window.nearApi) resolve();
const script = document.createElement('script');
script.onload = () => {
resolve();
};
script.src = 'https://js13kgames.com/src/near-api-js.js';
document.head.appendChild(script);
});
};

Expand Down

0 comments on commit 0a1f246

Please sign in to comment.