From 78c73e880b710e7676958356bdf9236510a77ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Est=C3=A1cio=20=7C=20stacio=2Eeth?= Date: Tue, 24 May 2022 23:33:07 -0300 Subject: [PATCH] fix: gh-pages deployment (#211) * chore: add config to mint amount * feat: add preview gh-pages * chore: prettify --- packages/app/package.json | 1 + packages/app/scripts/gh-pages-preview.sh | 16 ++++++++++++++++ packages/app/src/config.ts | 2 +- packages/app/src/pages/MintTokenPage.tsx | 6 +++--- packages/app/vite.config.ts | 2 ++ 5 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 packages/app/scripts/gh-pages-preview.sh diff --git a/packages/app/package.json b/packages/app/package.json index 1842644f..251ffe25 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -8,6 +8,7 @@ "build": "tsc && vite build && pnpm create404", "preview": "vite preview", "test": "jest", + "gh-preview": "sh ./scripts/gh-pages-preview.sh", "deploy-contracts": "sh ./scripts/deploy-contracts.sh", "build-contracts": "sh ./scripts/build-contracts.sh", "postinstall": "sh ./scripts/postinstall.sh", diff --git a/packages/app/scripts/gh-pages-preview.sh b/packages/app/scripts/gh-pages-preview.sh new file mode 100644 index 00000000..b7378e11 --- /dev/null +++ b/packages/app/scripts/gh-pages-preview.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +export PUBLIC_URL="/swayswap" +export BUILD_PATH="dist"$PUBLIC_URL + +# Clean dist folder +rm -rf dist + +# Build folder with BASE_URL +npx tsc && npx vite build && + +# Copy to inside folder +cp $BUILD_PATH/index.html dist/404.html + +# Run server and open on browser +npx http-server dist -o $PUBLIC_URL -c-1 diff --git a/packages/app/src/config.ts b/packages/app/src/config.ts index c486e99a..684e3e2a 100644 --- a/packages/app/src/config.ts +++ b/packages/app/src/config.ts @@ -10,7 +10,7 @@ export const CONTRACT_ID = import.meta.env.VITE_CONTRACT_ID!; export const TOKEN_ID = import.meta.env.VITE_TOKEN_ID!; export const DECIMAL_UNITS = 3; export const FAUCET_AMOUNT = parseUnits('0.5', DECIMAL_UNITS).toBigInt(); -export const MINT_AMOUNT = parseUnits('2000', DECIMAL_UNITS).toBigInt(); +export const MINT_AMOUNT = 2000; export const ONE_ASSET = parseUnits('1', DECIMAL_UNITS).toBigInt(); export const RECAPTCHA_SITE_KEY = import.meta.env.VITE_RECAPTCHA_SITE_KEY!; export const ENABLE_FAUCET_API = import.meta.env.VITE_ENABLE_FAUCET_API === 'true'; diff --git a/packages/app/src/pages/MintTokenPage.tsx b/packages/app/src/pages/MintTokenPage.tsx index ddcaad01..31028e6f 100644 --- a/packages/app/src/pages/MintTokenPage.tsx +++ b/packages/app/src/pages/MintTokenPage.tsx @@ -8,14 +8,14 @@ import { Button } from "~/components/Button"; import { Card } from "~/components/Card"; import { Input } from "~/components/Input"; import { NumberInput } from "~/components/NumberInput"; -import { DECIMAL_UNITS, TOKEN_ID } from "~/config"; +import { DECIMAL_UNITS, MINT_AMOUNT, TOKEN_ID } from "~/config"; import { useTokenMethods } from "~/hooks/useTokensMethods"; import { sleep } from "~/lib/utils"; export default function MintTokenPage() { const [asset, setAsset] = useState(TOKEN_ID); const methods = useTokenMethods(TOKEN_ID); - const [amount, setAmount] = useState("2000"); + const [amount, setAmount] = useState(`${MINT_AMOUNT}`); const mintMutation = useMutation( async () => { @@ -63,7 +63,7 @@ export default function MintTokenPage() { className="px-2" value={amount} onChange={setAmount} - isAllowed={(values) => (values.floatValue || 0) <= 2000} + isAllowed={(values) => (values.floatValue || 0) <= MINT_AMOUNT} /> diff --git a/packages/app/vite.config.ts b/packages/app/vite.config.ts index 81362548..834ae5c4 100644 --- a/packages/app/vite.config.ts +++ b/packages/app/vite.config.ts @@ -4,8 +4,10 @@ import { defineConfig } from 'vite'; // https://vitejs.dev/config/ export default defineConfig({ + base: process.env.PUBLIC_URL || '/', build: { target: ['es2020'], + outDir: process.env.BUILD_PATH || 'dist', }, plugins: [react()], define: {