gasgasgas/js/build.sh

34 lines
1.6 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
PUP_BIN=/home/lash/src/build/pup/pup
cat node_modules/openpgp/dist/openpgp.min.js node_modules/MimeJS/src/base64.js node_modules/MimeJS/dist/mime-js.min.js node_modules/jssha/dist/sha256.js run.js booteth/wallet.js booteth/session.js booteth/eip1193.js registry.js wala.js promise.js rpc.js > tmp.js
node node_modules/uglify-js/bin/uglifyjs tmp.js > src.js
echo -n "<html><head>" > standalone.html
cat index.html | $PUP_BIN "head title" >> standalone.html
cat index.html | $PUP_BIN "head style" >> standalone.html
echo -n "<script defer src='data:text/javascript;base64," >> standalone.html
base64 node_modules/alpinejs/dist/cdn.min.js -w0 >> standalone.html
echo -n "'></script>" >> standalone.html
#echo -n "<script>" >> standalone.html
#cat src.js >> standalone.html
#echo "</script><script type='module'>" >> standalone.html
echo -n "<script src='data:text/javascript;base64," >> standalone.html
base64 src.js -w0 >> standalone.html
echo "'></script><script type='module'>" >> standalone.html
echo -n "import { ethers } from 'data:text/javascript;base64," >> standalone.html
base64 node_modules/ethers/dist/ethers.min.js -w0 >> standalone.html
echo -en "';\nregister_ethers(ethers);\n</script><script type='module' src='data:text/javascript;base64," >> standalone.html
node node_modules/uglify-js/bin/uglifyjs main.js | base64 -w0 >> standalone.html
echo -n "'></script>" >> standalone.html
cat <<eof >> standalone.html
<script>
wallet_fallback = sessionwallet_create;
wallet_detect(ethers);
</script>
</head>
eof
cat index.html | $PUP_BIN "body" >> standalone.html
echo -n "</html>" >> standalone.html