Repository navigation
Migrate frontend from Create React App to Vite - #7
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #6. That PR cut frontend Dependabot alerts from 51 → 17 via
npm audit fixand targetedoverrides, but the remainder (webpack-dev-server/middleware, svgo/@svgr/plugin-svgo, jest/workbox family) had no safe fix short of removingreact-scripts(CRA) entirely — bumping webpack-dev-server brokenpm start, bumping svgo broke@svgr's SVG icon imports.This PR replaces
react-scriptswith Vite:frontend/vite.config.js:server.port: 3000(keeps the documented dev URL),server.proxyfor/task→localhost:8000(replaces CRA'spackage.json"proxy"field —App.js's relativefetch("/task/")is unchanged),build.outDir: 'build'(keeps the existing output directory).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.src/index.js/src/App.js→.jsx(Vite requires JSX content use a.jsx/.tsxextension).@testing-library/*— confirmed unused, no test files exist anywhere infrontend/src— and the CRA-onlyeslintConfig/browserslist/proxypackage.jsonfields.src/reportWebVitals.js, which called theweb-vitalsv2 API (getCLS/getFID/...) against the installed v4 package (onCLS/onINP/...) — silently broken independent of this migration.REACT_APP_BACKEND_URL=... npm startinstruction fromREADME.md(that env var was never actually read in code).Result:
npm auditinfrontend/now reports 0 vulnerabilities (was 17 after #6, 51 before it).Test plan
npm installresolves cleanly withreact-scriptsgone (0 vulnerabilities)npm run buildproduces a working production bundle inbuild/npm startboots the Vite dev server on port 3000http://localhost:3000/task/(i.e. through Vite's dev proxy, not hitting the backend directly) — round-tripped correctlybuild/output via a static file server and confirmed the HTML and JS asset load correctlypython tests/test_runtime.pyandpytest tests/test_integration.py -v(backend) still pass unchanged🤖 Generated with Claude Code