Skip to content

chore: migrate frontend from Create React App to Vite#221

Open
gmarav05 wants to merge 2 commits intoOpenLake:mainfrom
gmarav05:vite-migration
Open

chore: migrate frontend from Create React App to Vite#221
gmarav05 wants to merge 2 commits intoOpenLake:mainfrom
gmarav05:vite-migration

Conversation

@gmarav05
Copy link

@gmarav05 gmarav05 commented Jan 28, 2026


name: "Pull Request"
about: Propose and submit changes to the project for review
title: "PR: Migrate frontend from Create React App to Vite"
labels: "enhancement"
assignees: @harshitap1305 @sakshi1755 (not-assigned)

Related Issue


Changes Introduced

  • Added: Vite configuration (vite.config.js) with JSX support for .js files.
  • Added: React Router v7 future flags to prevent deprecation warnings.
  • Updated: index.html moved to root and converted from CRA to Vite format.
  • Updated: All module.exports converted to ES module syntax (export/import).
  • Updated: Environment variables from REACT_APP_* to VITE_* prefix.
  • Updated: package.json scripts to use Vite (dev, build, preview).
  • Removed: CRA dependencies (react-scripts).
  • Removed: Unused CRA files (reportWebVitals.js, setupTests.js, App.test.js).
  • Removed: %PUBLIC_URL% syntax from index.html.

Why This Change?

  • Problem: Create React App is slow, deprecated, and no longer actively maintained.
  • Solution: Migrate to Vite for faster development server startup and hot module replacement.
  • Impact: Developers benefit from significantly faster build times (~10s → ~500ms) and better development experience.

Screenshots / Video (if applicable)

Before After

Testing

  • Ran unit tests and all passed (npm test in the relevant directory).
  • Manually tested the following scenarios:
    • Test Case 1: [Describe steps + Expected Result]
    • Test Case 2: [Describe steps + Expected Result]
  • Tested on different browsers (Chrome, Firefox) for UI changes.
  • Verified there are no new console warnings or errors.

Documentation Updates

  • Updated the README.md with new instructions.
  • Added clear code comments where logic is complex.
  • N/A

Checklist

  • I have created a new branch for this PR (git checkout -b feature/my-amazing-feature).
  • I have starred the repository.
  • My code follows the project's coding style and conventions.
  • My commit messages are clear and follow the project's guidelines.
  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective or that my feature works.
  • All new and existing tests passed locally with my changes.
  • This PR introduces no breaking changes (or they are clearly documented).

Deployment Notes

  • Requires a database migration/schema update.
  • Requires new environment variables to be set.
  • N/A

💬 Additional Notes

  • Breaking Change: Environment variables must use VITE_ prefix instead of REACT_APP_.
  • Migration Guide:
    • process.env.REACT_APP_*import.meta.env.VITE_*.
    • Update .env files in all environments.
  • Build command remains npm run build, output goes to build/ folder.

Summary by CodeRabbit

  • Build Infrastructure
    • Migrated frontend build system from Create React App to Vite for faster development server and improved build performance.
    • Updated environment variable configuration format to align with Vite standards.
    • Streamlined development and production build workflows with optimized tooling.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Jan 28, 2026

@gmarav05 is attempting to deploy a commit to the openlake's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2026

Walkthrough

Migrates the React frontend from Create React App to Vite. Removes react-scripts and CRA-specific files, adds Vite configuration, updates environment variables from REACT_APP_* to VITE_*, converts module exports from CommonJS to ES modules, and restructures entry points for Vite compatibility.

Changes

Cohort / File(s) Summary
Build & Configuration
frontend/package.json, frontend/vite.config.js, frontend/.env.example
Replaced react-scripts with vite and @vitejs/plugin-react; updated scripts (dev, build, preview); created vite.config.js with React plugin, port 3000, and alias resolution; updated env var names to Vite convention
Entry Points
frontend/index.html (new), frontend/public/index.html (removed), frontend/src/main.jsx
Created root-level Vite entry point (index.html); removed CRA public template; updated main.jsx to remove reportWebVitals import and reorder CSS
Removed CRA Tooling
frontend/src/reportWebVitals.js, frontend/src/setupTests.js, frontend/src/App.test.js
Deleted performance monitoring, test setup (@testing-library/jest-dom), and unit test file—no longer needed with Vite
Environment Variable Migration
frontend/src/Components/Auth/Login.jsx, frontend/src/Components/Auth/Register.jsx, frontend/src/Components/President/PresidentDashboard.jsx, frontend/src/utils/api.js
Updated all references from process.env.REACT_APP_BACKEND_URL to import.meta.env.VITE_BACKEND_URL (Vite env pattern)
Module Export Updates
frontend/src/utils/getCurrentTenureRange.js, frontend/src/Components/Feedback/FeedbackStats.jsx
Converted getCurrentTenureRange from CommonJS (module.exports) to ES modules (named + default exports); updated import in FeedbackStats.jsx accordingly
Component Updates
frontend/src/App.jsx
Removed unused role-based logic and SidebarProvider wrapper; added BrowserRouter future props for React Router v7 compatibility

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 From Create React App, we bid adieu,
Vite's lightning-fast builds are fresh and new!
Env vars transformed, modules ES-bound,
Faster dev server spinning 'round and 'round! ⚡✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: migrating the frontend from Create React App to Vite.
Linked Issues check ✅ Passed The PR fulfills all coding requirements from issue #183: Vite configuration added, ES modules implemented, environment variables migrated to VITE_* prefix, CRA dependencies removed, React Router v7 flags applied, and index.html repositioned to root.
Out of Scope Changes check ✅ Passed All changes are directly aligned with the Vite migration objectives; no out-of-scope modifications detected. Changes include build tool migration, configuration updates, environment variable changes, and removal of CRA-specific files—all within scope of the migration.
Description check ✅ Passed The pull request description comprehensively follows the template structure with all major sections completed: Related Issue, Changes Introduced, Why This Change, Testing, Documentation Updates, Checklist, and Deployment Notes. It provides clear details about the migration from Create React App to Vite, including specific changes, rationale, and migration guidance.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/package.json (1)

50-54: ESLint config may be broken after removing react-scripts.

The eslintConfig still extends "react-app" and "react-app/jest", which are provided by react-scripts. Since react-scripts was removed, this configuration will likely fail.

🔧 Suggested fix: Update ESLint configuration for Vite

Consider removing the CRA-specific ESLint config and setting up a standalone ESLint configuration:

-  "eslintConfig": {
-    "extends": [
-      "react-app",
-      "react-app/jest"
-    ]
-  },

Then create an eslint.config.js or .eslintrc.json with appropriate React rules, or install eslint-plugin-react and eslint-plugin-react-hooks separately.

🤖 Fix all issues with AI agents
In `@frontend/src/Components/President/PresidentDashboard.jsx`:
- Around line 4-5: The project still reads Vite env var VITE_BACKEND_URL (see
API_BASE_URL constant in PresidentDashboard.jsx) but .env.example and docs
reference the old CRA variable; update .env.example to include
VITE_BACKEND_URL=http://localhost:8000 (and a short comment) and update
deployment documentation to require VITE_BACKEND_URL to be set in production,
removing or converting any REACT_APP_BACKEND_URL references so the Vite variable
name matches the runtime code.
- Line 3: The import in PresidentDashboard.jsx references a non-existent module
(navItems from presidentConfig); replace that import to pull NavbarConfig from
navbarConfig.js and update usages of navItems to use NavbarConfig.PRESIDENT (or
alternatively create a new presidentConfig export), i.e., change the import
statement and any references to navItems within the PresidentDashboard component
to reference NavbarConfig.PRESIDENT so the module resolves at runtime.
🧹 Nitpick comments (1)
frontend/package.json (1)

38-42: Test script was removed but testing dependencies remain.

The test script was removed, but testing libraries (@testing-library/jest-dom, @testing-library/react, @testing-library/user-event) are still listed in dependencies. If testing is still needed, consider adding Vitest as a replacement for Jest.

💡 If testing is needed, consider adding Vitest

Add Vitest for Vite-native testing:

"scripts": {
  "dev": "vite",
  "build": "vite build",
  "preview": "vite preview",
  "test": "vitest"
}

And add to devDependencies:

"vitest": "^1.0.0"

Alternatively, if testing is no longer needed, consider removing the unused testing dependencies to reduce bundle size.

import React, { useState, useEffect } from "react";
import { Link } from "react-router-dom";
import { navItems } from "../../config/presidentConfig.js";
import { navItems } from "../../config/presidentConfig";
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find presidentConfig file(s)
echo "=== Finding presidentConfig files ==="
fd -i "presidentconfig" -t f

Repository: OpenLake/Student_Database_COSA

Length of output: 111


🏁 Script executed:

#!/bin/bash
# Check config directory structure
echo "=== Config directory structure ==="
fd . "frontend/src/config" -t f 2>/dev/null || echo "Directory not found"

echo ""
echo "=== Searching for navItems definition globally ==="
rg -n "navItems" --type jsx --type js -A 2 -B 2

Repository: OpenLake/Student_Database_COSA

Length of output: 402


🏁 Script executed:

#!/bin/bash
echo "=== Searching for navItems definition ==="
rg -n "navItems" --type js

echo ""
echo "=== Checking navbarConfig.js (likely source) ==="
cat -n "frontend/src/config/navbarConfig.js" | head -30

echo ""
echo "=== Checking PresidentDashboard.jsx imports ==="
head -20 "frontend/src/Components/President/PresidentDashboard.jsx"

Repository: OpenLake/Student_Database_COSA

Length of output: 2571


🏁 Script executed:

#!/bin/bash
echo "=== Full NavbarConfig structure ==="
cat "frontend/src/config/navbarConfig.js"

Repository: OpenLake/Student_Database_COSA

Length of output: 2843


Fix the import path—presidentConfig.js does not exist.

The file frontend/src/config/presidentConfig.js is missing. Import NavbarConfig from navbarConfig.js instead and use NavbarConfig.PRESIDENT where navItems is referenced, or create the missing presidentConfig file. Without this fix, the component will crash at runtime when attempting to load the module.

🤖 Prompt for AI Agents
In `@frontend/src/Components/President/PresidentDashboard.jsx` at line 3, The
import in PresidentDashboard.jsx references a non-existent module (navItems from
presidentConfig); replace that import to pull NavbarConfig from navbarConfig.js
and update usages of navItems to use NavbarConfig.PRESIDENT (or alternatively
create a new presidentConfig export), i.e., change the import statement and any
references to navItems within the PresidentDashboard component to reference
NavbarConfig.PRESIDENT so the module resolves at runtime.

Comment on lines 4 to +5
const API_BASE_URL =
process.env.REACT_APP_BACKEND_URL || "http://localhost:8000";
import.meta.env.VITE_BACKEND_URL || "http://localhost:8000";
Copy link
Contributor

@coderabbitai coderabbitai bot Jan 28, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check for VITE_BACKEND_URL in env files
echo "=== Checking for VITE_BACKEND_URL in .env files ==="
fd -H '\.env' --type f -x grep -n 'VITE_BACKEND_URL' {} +

echo ""
echo "=== Checking for old CRA-style env vars ==="
rg -n "process\.env\.REACT_APP|REACT_APP_BACKEND_URL" --type js --type jsx

Repository: OpenLake/Student_Database_COSA

Length of output: 285


🏁 Script executed:

#!/bin/bash
# First, list all .env files in the repo
echo "=== .env files in repository ==="
find . -type f -name "\.env*" 2>/dev/null | head -20

echo ""
echo "=== Searching for VITE_BACKEND_URL in .env files ==="
find . -type f -name "\.env*" -exec grep -H 'VITE_BACKEND_URL' {} \;

echo ""
echo "=== Searching for old REACT_APP env vars in codebase ==="
rg "process\.env\.REACT_APP|REACT_APP_BACKEND_URL" -i

echo ""
echo "=== Checking where VITE_BACKEND_URL is actually used ==="
rg "VITE_BACKEND_URL" 

echo ""
echo "=== Checking for import.meta.env usage ==="
rg "import\.meta\.env\."

Repository: OpenLake/Student_Database_COSA

Length of output: 1439


🏁 Script executed:

cat frontend/.env.example

Repository: OpenLake/Student_Database_COSA

Length of output: 162


Update .env.example to reflect Vite migration and ensure VITE_BACKEND_URL is configured in all deployments.

The .env.example file still contains old CRA-style variables (REACT_APP_BACKEND_URL), but the codebase has migrated to Vite and uses VITE_BACKEND_URL. The environment variable is undefined in .env files, causing the fallback to localhost:8000 to silently mask missing configuration in production. Update .env.example to document VITE_BACKEND_URL=http://localhost:8000 and ensure deployment documentation explicitly requires this variable to be set.

🤖 Prompt for AI Agents
In `@frontend/src/Components/President/PresidentDashboard.jsx` around lines 4 - 5,
The project still reads Vite env var VITE_BACKEND_URL (see API_BASE_URL constant
in PresidentDashboard.jsx) but .env.example and docs reference the old CRA
variable; update .env.example to include VITE_BACKEND_URL=http://localhost:8000
(and a short comment) and update deployment documentation to require
VITE_BACKEND_URL to be set in production, removing or converting any
REACT_APP_BACKEND_URL references so the Vite variable name matches the runtime
code.

Copy link
Author

Choose a reason for hiding this comment

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

maybe i should update this.

Copy link
Contributor

Choose a reason for hiding this comment

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

@gmarav05 Yes, updating .env.example is definitely the right move! Since you've migrated the codebase to Vite, the environment variable names in your example file should match what the code actually expects.

You'll want to update all the REACT_APP_* variables in frontend/.env.example to VITE_*:

  • REACT_APP_BACKEND_URLVITE_BACKEND_URL
  • REACT_APP_FIREBASE_API_KEYVITE_FIREBASE_API_KEY
  • REACT_APP_FIREBASE_AUTH_DOMAINVITE_FIREBASE_AUTH_DOMAIN

Would you like me to help plan these changes? I can generate the updated .env.example file for you—just let me know! 🚀

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@frontend/.env.example`:
- Around line 1-2: Add a trailing newline to the .env example so dotenv-linter
stops flagging it: open frontend/.env.example and ensure the file ends with a
single blank line (i.e., a newline character after the last line containing
VITE_GOOGLE_CLIENT_ID=your_google_client_id_here) so the environment variables
VITE_BACKEND_URL and VITE_GOOGLE_CLIENT_ID are followed by a final newline.
🧹 Nitpick comments (1)
frontend/index.html (1)

10-13: Update the meta description to remove CRA default text.

This still says “create-react-app,” which is now stale after the Vite migration.

✏️ Suggested tweak
-    <meta
-      name="description"
-      content="Web site created using create-react-app"
-    />
+    <meta
+      name="description"
+      content="CoSA ERP"
+    />

@harshitap1305 harshitap1305 self-requested a review January 28, 2026 11:35
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.

[FOSSOVERFLOW-25] feat: migrate frontend from create-react-app to vite

1 participant