Skip to content

Move the build from Create React App to Vite - #99

Merged
kuzdogan merged 2 commits into
stagingfrom
feat/vite-migration
Oct 29, 2026
Merged

kuzdogan merged 2 commits into
stagingfrom
feat/vite-migration

Conversation

@kuzdogan

@kuzdogan kuzdogan commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Addresses argotorg/sourcify#3035 (move sourcify.dev from Create React App to Vite).

Summary

This PR replaces Create React App (react-scripts 5.0.1) with Vite 8. Vite is a build tool and dev server for front-end apps.

  • For a visitor: nothing changes. The pages, URLs and assets stay the same.
  • For a developer:
    • npm run dev (or npm start) starts the dev server on port 3000, as before.
    • Env vars now start with VITE_, not REACT_APP_. The code reads them from import.meta.env, not process.env.
    • Node must be 22.13 or newer. .nvmrc and the deploy workflow now pin 22.23.4.
    • npm test runs the existing unit tests with Vitest.

Why

Create React App is no longer maintained. react-scripts pins webpack-dev-server 4 and svgo 1. Both have known CVEs (published security flaws). We cannot update them while we use react-scripts.

The install also gets much smaller. npm ci installs 398 packages now. On staging it installs 1428.

Socket result

Socket checks npm packages for known risks. I ran npm ci through socket npm on a clean node_modules. The table shows the five packages from the issue.

Package Before After
webpack-dev-server 4.15.2 flagged gone (it came from react-scripts)
svgo 1.3.2 flagged gone (it came from react-scripts)
postcss-selector-parser 6.1.4 flagged fixed: a new override pins 6.1.5. Tailwind still needs it.
sprintf-js 1.0.3 flagged gone (it came from build tools in react-scripts)
elliptic 6.6.1 flagged still installed through @ethersproject/signing-key. Socket does not flag it in this run. It is not in the bundle.

Socket now flags one package: undici 6.29.0 (a moderate CVE). It is already on staging. It comes from @ai-sdk/provider-utils, which the ai package uses. This PR does not change it. undici 6.29.1 exists and is in range, so a lockfile update can probably fix it in a separate PR.

Build comparison

I built staging (Create React App) and this branch (Vite) with the same .env.build.staging.

  • Public files: all files from public/ are in build/, byte for byte the same.
  • index.html head: the same meta tags, title, Umami script (with the real website id), and hash-URL migration script. No %PUBLIC_URL% or %VITE_…% placeholder is left.
  • Env values: every staging URL is in the bundle. process.env does not occur in the bundle.
  • Sizes (gzip):
Create React App Vite
Main JS bundle 231.7 kB 212.0 kB
All JS 359.2 kB (6 files) 331.7 kB (5 files)
CSS 8.7 kB 8.2 kB

Differences in the output:

  • Assets are in build/assets/, not in build/static/. The deploy workflow uploads all of build/, so this does not matter. The workflow keeps static/stats.json and static/manifest.json in the bucket. The build does not write these files, so the change has no effect on them.
  • The build has no source maps (*.map). Create React App made 8 of them (16 MB). Set build.sourcemap: true in vite.config.mts if we want them back.
  • The build has no asset-manifest.json. Nothing in the repo reads it.

Smoke test

I ran npm run dev (with .env.development) and opened these pages in Chrome. I saw no console errors.

  • /: the hero, the live counter and the stats load. All 31 images load, also the 5 chain logos that use new URL(…, import.meta.url). The IBM Plex and VT323 fonts load.
  • /address/0xd61dAdFb716Aa65aA29E7CF6E15Ed833a403dcd6: the lookup shows the Sepolia match.
  • /#/lookup/0xd61d… changes to /address/0xd61d….
  • /#dataset-playground changes to /dataset-playground. The OpenRouter key from .env.development reaches the page.
  • /verifier shows the staging verify URL.

Then I ran npm run preview on the staging build. A direct load of /dataset-playground renders the page, so the fallback to index.html works.

Fixes that the move needed

The Google Fonts @import in src/index.css. It came after the Tailwind lines:

@tailwind base;
@tailwind components;
@tailwind utilities;

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:...&display=swap");

CSS allows @import only at the top of a file. Create React App moved it up without a warning. Vite drops it, so the fonts did not load. The @import is now the first line.

The one test file, src/pages/LandingPage/liveStats.test.ts. It imported describe, it and expect from @jest/globals. Jest came only from react-scripts. The file now imports them from vitest, and npm test runs vitest run. All 12 tests pass. Vitest 5 needs @types/node 22 or newer, so @types/node goes from 20.19.43 to 22.20.5. This matches the new Node pin.

A missing image. index.html linked %PUBLIC_URL%/logo192.png, which does not exist in public/. The apple-touch-icon link now points to /sourcify_blue_rounded.png.

Overrides. on-headers, serialize-javascript and uuid are no longer installed, so their overrides go away. The react-scripts block goes away too. prismjs stays.

Lint

The old ESLint config extended react-app from react-scripts. The new eslint.config.mjs is a flat config, based on the official Vite react-ts template. It uses ESLint 10, the current version. npm run lint checks the files in src/ and vite.config.mts.

I fixed the mechanical errors:

  • In bigquery in src/utils/api.tsx, the unused e now goes into the new error as its cause:
    } catch (e) {
      throw new Error("Cannot parse the error message", { cause: e });
    }
  • In the model check in AIGenerator (src/components/BigQueryExplorer/AIGenerator.tsx), catch (e: any) becomes catch. A react-hooks/exhaustive-deps disable comment that no longer suppresses anything is gone.
  • In BigQueryExplorer (src/components/BigQueryExplorer/index.tsx), the two empty catch {} blocks around localStorage now have a comment that explains why they are empty.

These rules flag code that works today. A fix needs a refactor, so they are set to warn (25 warnings in total):

Rule Hits What it flags
@typescript-eslint/no-explicit-any 10 any types
react-refresh/only-export-components 7 files that export components and other values. Hot reload then reloads the full page.
react-hooks/set-state-in-effect 6 setState called directly in a useEffect
react-hooks/refs 1 a ref read during render in LiveFeed.tsx
react-hooks/purity 1 Date.now() during render in VerifiedContracts.tsx

tsc --noEmit reports no type errors. npm run build runs it before vite build, the same as Create React App type-checked during its build.

Other changes

  • vite.config.mts and eslint.config.mjs use ES module file extensions. package.json has no "type": "module", and postcss.config.js and tailwind.config.js use CommonJS.
  • README.md describes the new commands and env vars. The Docker section is gone, because the repo has no Dockerfile.

Settings outside the repo

No setting outside the repo needs to change.

  • The build runs on GitHub Actions. The env values come from .env.build.staging and .env.build.main, and this PR renames their keys.
  • The one GitHub secret, REACT_APP_OPENROUTER_API_KEY, keeps its name. The workflow passes it to the build as VITE_OPENROUTER_API_KEY.
  • Netlify reads the Node version from .nvmrc and runs npm run build. The publish directory stays build/. The deploy preview of this PR builds with the staging URLs.

Changes after the review

  • Umami: a small plugin in vite.config.mts adds the Umami script only when VITE_UMAMI_WEBSITE_ID is set. Dev and Netlify previews set it to empty, so they load no analytics script. Before, they shipped the %VITE_UMAMI_WEBSITE_ID% placeholder.
  • Browsers: build.target is now the oldest browsers that the Create React App build supported (Chrome 109, Safari/iOS 15.6, Firefox 115). Without it, Vite targets Chrome 111 and Safari 16.4. The main bundle is now 215.7 kB gzip (212.0 kB before this change).
  • CI: a new ci.yaml workflow runs lint, unit tests, the build and Playwright smoke tests (npm run test:e2e) on every pull request.
  • Cleanups: VERIFY_URL comes from constants.ts everywhere. engines asks for Node 22.13+. nginx.conf is gone. tsconfig.node.json type-checks the config files. release.yaml explains why the OpenRouter key is in the bundle.

🤖 Generated with Claude Code

Create React App (react-scripts 5.0.1) is no longer maintained. It pins
webpack-dev-server 4 and svgo 1, which have known CVEs. Vite replaces it.

- Vite builds the site into build/, as before. The dev server stays on port 3000.
- index.html moves from public/ to the repository root.
- Env vars change from REACT_APP_* (process.env) to VITE_* (import.meta.env).
  The GitHub secret keeps its old name; the workflow maps it.
- Node goes to 22.23.4 in .nvmrc and the workflow. Vite 8 needs 22.12 or newer.
- An ESLint flat config replaces the CRA ESLint config.
- Vitest replaces Jest for the one existing test file.
- The Google Fonts @import moves to the top of index.css. Vite drops an
  @import that comes after other rules; CRA moved it up silently.
- The apple-touch-icon link points to an image that exists.
- Overrides for on-headers, serialize-javascript and uuid go away, because
  these packages are no longer installed. A new override pins
  postcss-selector-parser to 6.1.5.

Addresses argotorg/sourcify#3035 (move sourcify.dev from Create React App to Vite).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@netlify

netlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for sourcify-dev ready!

Name Link
🔨 Latest commit 748c3b5
🔍 Latest deploy log https://app.netlify.com/projects/sourcify-dev/deploys/6ae33384783c4dda8d23c812
😎 Deploy Preview https://deploy-preview-99--sourcify-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@kuzdogan kuzdogan moved this to Sprint - Needs Review in Sourcify Public Oct 28, 2026

@manuelwedler manuelwedler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked out the branch: npm ci, npm run build, npm run lint (0 errors, 25 warnings) and npm test (12/12) all pass.

The main finding is that the Umami placeholder ships literally in dev and in Netlify previews (index.html). There is also a browser-support change from the new default Vite build target, and nothing runs the tests or lint automatically. The OpenRouter key in the bundle is an older issue and does not block this PR. The rest are nits.


Generated by Claude Code

Comment thread index.html Resolved
Comment thread .github/workflows/release.yaml Resolved
Comment thread vite.config.mts Resolved
Comment thread package.json Resolved
Comment thread src/components/Header/index.tsx Resolved
Comment thread README.md Resolved
Comment thread README.md Resolved
Comment thread tsconfig.json Resolved
- Add the Umami script only when VITE_UMAMI_WEBSITE_ID is set, through a
  small plugin in vite.config.mts. Set it to empty in .env.development and
  netlify.toml, so dev and previews load no analytics script.
- Set build.target to the oldest browsers that the Create React App build
  supported (Chrome 109, Safari/iOS 15.6, Firefox 115).
- Add a CI workflow for pull requests: lint, unit tests, build and
  Playwright smoke tests against the build.
- Read VERIFY_URL from constants.ts everywhere.
- Require Node.js 22.13 or newer (README and engines).
- Remove nginx.conf, which only the old Docker setup used.
- Type-check vite.config.mts and the Playwright files with tsconfig.node.json.
  Remove the duplicate vite/client reference.
- Explain in release.yaml why the OpenRouter key is in the bundle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013vUbuRRw2eZLCJwQ4jY2VY
@kuzdogan
kuzdogan requested a review from manuelwedler October 29, 2026 11:53

@manuelwedler manuelwedler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-reviewed 748c3b5. All earlier comments are addressed, and I resolved the threads.

What I checked locally:

  • npm ci, npm run lint (0 errors), npm test (12/12), and npm run build (which now also type-checks tsconfig.node.json) all pass.
  • Umami: a build without the id has no tag. A build with .env.build.staging has the tag with the right data-website-id. A build where the process env sets it to empty overrides .env, as the CI workflow expects. The deploy preview has no Umami tag and no %VITE_…% placeholder.
  • Browser target: today >0.2%, not dead, not op_mini all resolves to chrome 109, edge 119, firefox 120 and ios_saf 15.6. The new build.target is the same or older, so no supported browser is lost.
  • Smoke tests: 4/4 pass locally and in the new CI job. When I block the staging backend, the landing page still renders with no page errors, so the tests do not become flaky when staging is down.

LGTM.


Generated by Claude Code

@kuzdogan
kuzdogan merged commit 3ee5e61 into staging Oct 29, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from Sprint - Needs Review to Sprint - Done in Sourcify Public Oct 29, 2026
@kuzdogan
kuzdogan deleted the feat/vite-migration branch October 29, 2026 12:10
@marcocastignoli marcocastignoli moved this from Sprint - Done to COMPLETED in Sourcify Public Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants