Skip to content

Migrate frontend from Create React App to Vite - #7

Merged
sis0k0 merged 1 commit into
mainfrom
migrate-frontend-to-vite
Nov 15, 2026
Merged

sis0k0 merged 1 commit into
mainfrom
migrate-frontend-to-vite

Conversation

@sis0k0

@sis0k0 sis0k0 commented Nov 15, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to #6. That PR cut frontend Dependabot alerts from 51 → 17 via npm audit fix and targeted overrides, but the remainder (webpack-dev-server/middleware, svgo/@svgr/plugin-svgo, jest/workbox family) had no safe fix short of removing react-scripts (CRA) entirely — bumping webpack-dev-server broke npm start, bumping svgo broke @svgr's SVG icon imports.

This PR replaces react-scripts with Vite:

  • New frontend/vite.config.js: server.port: 3000 (keeps the documented dev URL), server.proxy for /task → localhost:8000 (replaces CRA's package.json "proxy" field — App.js's relative fetch("/task/") is unchanged), build.outDir: 'build' (keeps the existing output directory).
  • Moved public/index.html → frontend/index.html (Vite's entry-HTML convention), swapped %PUBLIC_URL% placeholders for root-relative paths, added the explicit <script type="module"> entry tag CRA used to inject automatically.
  • Renamed src/index.js/src/App.js → .jsx (Vite requires JSX content use a .jsx/.tsx extension).
  • Dropped @testing-library/* — confirmed unused, no test files exist anywhere in frontend/src — and the CRA-only eslintConfig/browserslist/proxy package.json fields.
  • Fixed src/reportWebVitals.js, which called the web-vitals v2 API (getCLS/getFID/...) against the installed v4 package (onCLS/onINP/...) — silently broken independent of this migration.
  • Dropped the dead REACT_APP_BACKEND_URL=... npm start instruction from README.md (that env var was never actually read in code).

Result: npm audit in frontend/ now reports 0 vulnerabilities (was 17 after #6, 51 before it).

Test plan

  • npm install resolves cleanly with react-scripts gone (0 vulnerabilities)
  • npm run build produces a working production bundle in build/
  • npm start boots the Vite dev server on port 3000
  • End-to-end dev-proxy smoke test: with the backend running against local MongoDB, created and listed a task through http://localhost:3000/task/ (i.e. through Vite's dev proxy, not hitting the backend directly) — round-tripped correctly
  • Served the production build/ output via a static file server and confirmed the HTML and JS asset load correctly
  • python tests/test_runtime.py and pytest tests/test_integration.py -v (backend) still pass unchanged

🤖 Generated with Claude Code

react-scripts@5.0.1 (CRA) is unmaintained since 2022 and pins old,
vulnerable versions of webpack-dev-server, svgo/@svgr, jest, and
workbox deep in its dependency tree. A prior round of npm audit
fix + targeted overrides got frontend Dependabot alerts from 51 to
17, but the remaining alerts had no safe fix short of removing
react-scripts entirely (bumping webpack-dev-server/middleware breaks
`npm start`; bumping svgo breaks @svgr's SVG icon imports).

Changes:
- Replace react-scripts with vite + @vitejs/plugin-react. New
  frontend/vite.config.js sets server.port=3000 (preserving the
  documented dev URL), server.proxy for '/task' -> localhost:8000
  (replacing CRA's package.json "proxy" field so App.js's relative
  fetch("/task/") keeps working), and build.outDir='build' (keeping
  the existing output directory).
- Move public/index.html to frontend/index.html (Vite's entry-HTML
  convention), replace %PUBLIC_URL% placeholders with root-relative
  paths, and add the explicit <script type="module"> entry tag that
  CRA used to inject automatically.
- Rename src/index.js and src/App.js to .jsx (Vite requires JSX
  content use a .jsx/.tsx extension; CRA's babel pipeline didn't).
- Drop @testing-library/* (confirmed unused — no test files exist
  anywhere in frontend/src) and the CRA-specific eslintConfig/
  browserslist/proxy package.json fields.
- Fix src/reportWebVitals.js, which called the web-vitals v2 API
  (getCLS/getFID/...) against the installed v4 package (onCLS/onINP/
  ...) -- this was silently broken independent of this migration.
- Drop the unused REACT_APP_BACKEND_URL instruction from README.md
  (confirmed dead: that env var was never read anywhere in the code).

Result: frontend npm audit now reports 0 vulnerabilities (was 17).

Verified: `npm run build` produces a working production bundle,
`npm start` serves the Vite dev server on port 3000 with the /task
proxy working end-to-end against a running backend (created and
listed a task through the proxy), the production build/ output
serves correctly via a static file server, and the backend unit +
integration test suites still pass unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@sis0k0
sis0k0 requested a review from a team as a code owner November 15, 2026 07:47
@sis0k0
sis0k0 merged commit 4df0fd6 into main Nov 15, 2026
5 checks passed
@sis0k0
sis0k0 deleted the migrate-frontend-to-vite branch November 15, 2026 07:48
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.

1 participant