Skip to main content

Claude/ChatGPT Prompt to Migrate a CRA or Webpack App to Vite

Get a step-by-step migration plan from Create React App or Webpack to Vite, with file diffs, test setup, and a rollback path.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt casts the model as a senior frontend build engineer and asks it to produce a concrete, follow-blind migration plan from Create React App or Webpack to Vite. Instead of a vague "switch your bundler" overview, it forces actual file diffs: dependency changes, a vite.config.ts, the index.html move, the entry point rewrite, and env var renames. The framing — "return actual file diffs, not vague steps" — is what keeps the output executable rather than aspirational.

The variables shape how specific the plan gets. [source_setup] tells the model whether you are on CRA 5 or a hand-rolled Webpack config, which changes the exact files it touches. [test_runner] drives section 4 — the Jest-to-Vitest config and mock migration looks very different from a Mocha setup. [ci] tailors the install, build, and cache steps to your pipeline so the CI section is copy-ready rather than generic.

When to use it

  • You are moving a CRA or Webpack app to Vite mainly for dev-server speed and HMR
  • You want the long-tail gotchas (process.env, require, dynamic imports) surfaced before they break CI
  • You need a Jest-to-Vitest test migration mapped out, not just the build swap
  • Your CI pipeline needs explicit install/build/cache adjustments for the new toolchain
  • You want a rollback path ready before you merge, not improvised after a red build
  • You are handing the migration to someone who needs each step as a literal diff

Example output

The model returns an ordered checklist where each step carries the actual file diff to apply — a prerequisites block (Node version, lockfile, CRA/Webpack feature inventory), then dependency and config diffs, an index.html move, entry-point changes, CI edits for your system, a test-runner migration section, a gotchas list, and a final rollback plan. It reads like a PR description you can execute top to bottom.

Pro tips

  • Fill [source_setup] precisely ("Create React App 5 with CRACO overrides") — overrides and ejected configs change which steps apply
  • If your [test_runner] is Jest, expect a Vitest config plus mock rewrites; flag any custom transformers so they are not silently dropped
  • Set [ci] to your real system so the cache keys and build commands match; a generic answer often caches the wrong directory
  • Push the model hard on the gotchas section — process.env access, CommonJS require, and dynamic imports are where CRA hid complexity that Vite exposes
  • Keep the rollback branch alive until the new build is green in CI for a full cycle; dynamic imports can resolve differently and only show up under load
  • Iterate by pasting back any CI error and asking it to amend the specific diff rather than regenerating the whole plan

Frequently Asked Questions

Does this prompt handle the Jest to Vitest test migration too?
Yes. Deliverable 4 covers migrating from whatever you set in `[test_runner]`, including the new config file and how to port mocks. If you are on Jest it maps you to Vitest with the equivalent setup, but you should still flag any custom transformers so they are not dropped.
Will it catch process.env and require usage that CRA allowed?
That is the point of the gotchas deliverable. The prompt explicitly asks the model to surface `process.env` access, CommonJS `require` calls, dynamic imports, and absolute import aliases, since those are the parts CRA and Webpack hid that break under Vite.
Can I use this for a custom Webpack config rather than Create React App?
Yes, set `[source_setup]` to describe your Webpack setup. The more detail you give about loaders, plugins, and overrides, the more accurately the model maps each one to its Vite equivalent rather than assuming a stock CRA layout.
Does the output include a rollback plan if CI breaks?
Deliverable 6 is a rollback plan to revert cleanly if the build fails in CI. Keep that branch ready until the new build is stable, because dynamic imports sometimes resolve differently and only surface after the migration looks complete.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Frontend Development Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support