Skip to content

Migrate from Create React App to Vite#11

Draft
MatissJanis wants to merge 3 commits into
masterfrom
claude/upgrade-vite-migration-P8jVK
Draft

Migrate from Create React App to Vite#11
MatissJanis wants to merge 3 commits into
masterfrom
claude/upgrade-vite-migration-P8jVK

Conversation

@MatissJanis
Copy link
Copy Markdown
Member

Summary

This PR migrates the project from Create React App (CRA) with react-scripts to Vite as the build tool and Vitest for testing. This modernizes the build pipeline with faster development server startup and HMR, while also updating all dependencies to their latest versions.

Key Changes

Build Tool Migration

  • Replaced react-scripts with Vite and @vitejs/plugin-react
  • Created new vite.config.ts with custom Chrome extension manifest generation plugin
  • Removed config-overrides.js (CRA customization file)
  • Moved public/index.html to root index.html with module script reference
  • Updated build output configuration to maintain extension compatibility

Testing Framework Migration

  • Replaced Jest with Vitest
  • Updated src/setupTests.ts to use Vitest imports and mocking API
  • Added jsdom environment configuration for DOM testing
  • Updated test scripts: test runs once, test:watch for watch mode

Environment Variables

  • Migrated from REACT_APP_* to VITE_* prefix convention
  • Updated .env file with new variable names
  • Created src/vite-env.d.ts for Vite client type definitions
  • Updated all source files to use import.meta.env instead of process.env

TypeScript Configuration

  • Updated tsconfig.json:
    • Changed target from es5 to ES2020
    • Changed moduleResolution from node to bundler
    • Added path alias for src/*
    • Added Vite and Vitest type references
    • Restricted includes to src and vite.config.ts

Dependency Updates

  • Updated major versions: React 18.0.0 → 18.3.1, TypeScript 4.6.4 → 5.9.3
  • Updated build/dev tools: Prettier 2.0.5 → 3.5.3, Husky 8.0.1 → 9.1.7
  • Updated UI libraries: Nivo 0.85.1 → 0.99.0, Semantic UI React 2.0.1 → 2.1.5
  • Replaced graphql-anywhere with direct type imports (removed unused dependency)
  • Replaced query-string with qs for query parameter handling

Source Code Updates

  • Updated component type definitions for Nivo chart layers to use new API
  • Fixed type annotations in PropertyPriceChart.tsx for Nivo v0.99.0 compatibility
  • Added type casting workaround for react-places-autocomplete compatibility
  • Updated all environment variable references throughout the codebase
  • Updated GitHub Actions workflow to use actions/checkout@v4

Package.json Metadata

  • Added "type": "module" for ES modules
  • Added description and author fields
  • Updated scripts: startdev, added preview, updated build and test
  • Added resolutions field to pin React types versions

Notable Implementation Details

  • The Vite config includes a custom plugin that generates the Chrome extension manifest dynamically during build
  • The extension is automatically packaged as extension.zip using vite-plugin-zip-pack
  • Build output maintains the same structure as CRA for extension compatibility (single js/bundle.js file)
  • Minification is disabled to match original CRA behavior for extension debugging

https://claude.ai/code/session_01MAoY1GeP9o8DuUPS9ETvDw

claude and others added 3 commits March 28, 2026 01:42
…encies

Replace CRA (react-scripts 5.0.1) with Vite 7 for faster builds and dev server,
and Jest with Vitest for testing. Upgrade all dependencies to latest compatible
versions while keeping React 18.x and react-table v7 for compatibility.

Key changes:
- Add vite.config.ts with Chrome extension manifest plugin and zip packaging
- Move index.html to project root (Vite convention)
- Migrate env vars from REACT_APP_* to VITE_* (import.meta.env)
- Update tsconfig for Vite (moduleResolution: bundler, ES2020 target)
- Fix type errors from upgraded @nivo, react-datepicker, react-error-boundary
- Update CI workflow to use actions/checkout@v4
- Remove CRA-specific files (config-overrides.js, react-app-env.d.ts)

https://claude.ai/code/session_01MAoY1GeP9o8DuUPS9ETvDw
…rn 4

- Skip Bugsnag initialization when no API key is set (fixes dev crash)
- Update husky config to modern v9+ format (fixes deprecation warning)
- Migrate from Yarn 1 to Yarn 4 with node-modules linker
- Update CI workflows to use --immutable instead of --frozen-lockfile

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants