From bc3977c129c57a1f823198bdc194ded4c6f04e9e Mon Sep 17 00:00:00 2001 From: Alain Nicolas Date: Thu, 4 Jan 2024 23:21:44 +0100 Subject: [PATCH] chore: When the Explorer is deployed in production, remove the `HashRouter` --- .github/workflows/explorer-deploy-preview.yml | 2 +- .github/workflows/explorer-deploy-prod.yml | 2 +- explorer/package.json | 4 +++- explorer/src/routes/index.tsx | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/explorer-deploy-preview.yml b/.github/workflows/explorer-deploy-preview.yml index 1ed52d36..5eea6f0d 100644 --- a/.github/workflows/explorer-deploy-preview.yml +++ b/.github/workflows/explorer-deploy-preview.yml @@ -65,7 +65,7 @@ jobs: - name: Build if: steps.check-changes.outputs.changed == 'true' - run: pnpm run build + run: pnpm run build:netlify env: VITE_WALLETCONNECT_PROJECT_ID: ${{ secrets.VITE_WALLETCONNECT_PROJECT_ID }} VITE_INFURA_API_KEY: ${{ secrets.VITE_INFURA_API_KEY }} diff --git a/.github/workflows/explorer-deploy-prod.yml b/.github/workflows/explorer-deploy-prod.yml index 20e55c16..c99b3c19 100644 --- a/.github/workflows/explorer-deploy-prod.yml +++ b/.github/workflows/explorer-deploy-prod.yml @@ -48,7 +48,7 @@ jobs: run: pnpm install --frozen-lockfile - name: Build - run: pnpm run build + run: pnpm run build:netlify env: VITE_WALLETCONNECT_PROJECT_ID: ${{ secrets.VITE_WALLETCONNECT_PROJECT_ID }} VITE_INFURA_API_KEY: ${{ secrets.VITE_INFURA_API_KEY }} diff --git a/explorer/package.json b/explorer/package.json index 78390e05..8bca1beb 100644 --- a/explorer/package.json +++ b/explorer/package.json @@ -17,9 +17,11 @@ "type": "module", "scripts": { "build": "tsc && vite build", + "build:netlify": "pnpm run build && pnpm run redirect", "dev": "vite", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", - "preview": "vite preview" + "preview": "vite preview", + "redirect": "touch dist/_redirects && echo '/* /index.html 200' >> dist/_redirects" }, "dependencies": { "@radix-ui/react-dropdown-menu": "^2.0.6", diff --git a/explorer/src/routes/index.tsx b/explorer/src/routes/index.tsx index 675d6be6..50fa9944 100644 --- a/explorer/src/routes/index.tsx +++ b/explorer/src/routes/index.tsx @@ -1,4 +1,4 @@ -import { Route, createHashRouter, createRoutesFromElements } from "react-router-dom"; +import { Route, createBrowserRouter, createRoutesFromElements } from "react-router-dom"; import { Attestation } from "@/pages/Attestation"; import { Attestations } from "@/pages/Attestations"; @@ -17,7 +17,7 @@ import { loaderNetworkProvider } from "@/providers/network-provider/loader"; import { APP_ROUTES } from "./constants"; import { NotFoundPage } from "./NotFoundPage"; -export const router = createHashRouter( +export const router = createBrowserRouter( createRoutesFromElements( } loader={loaderNetworkProvider}> } />