Skip to main content
← Guides

Guide

Migrating React and Vue Apps from Vite 7 to Vite 8

Updated PkgPulse Team8 min read
0

Upgrade React and Vue apps from Vite 7 to Vite 8. Check Rolldown config, plugin compatibility, SSR output and CI before switching builds, with a rollback plan.

Contents

Upgrade Vite first. Keep your React or Vue runtime and framework plugin if their peer ranges allow it, and keep your deployment settings fixed. Start from a passing Vite 7 build on the Node version CI uses. After a clean install on Vite 8, serve the production build and check that the same entry point, styles and lazy routes load at the same public path.

Vite 8 uses Rolldown for dependency optimization and production bundling, and Oxc for JavaScript transforms. Check emitted assets, build plugins and server-side rendering (SSR) against the built release. Vite release notes

Capture the Vite 7 baseline

Check the Node version on your workstation, build runner and container image. The Vite 8 release tested here declares ^20.19.0 || >=22.12.0. If CI needs a new Node version, try it with the old lockfile first. Check the production runtime separately if it runs an SSR bundle. Vite package manifest

Keep a known-good release and record its commit, lockfile, build mode, public base and deployment runtime. Capture the built HTML and any manifests or asset lists the server consumes. Pick a route with a lazy import and a style or asset that loads with it. If the app renders on the server, use a direct request to that route and record the expected HTML and the interaction that confirms hydration.

Commit the Vite version and lockfile update together. In an npm project, npm install -D --save-exact vite@8.4.1 pins the dependency tested in this guide. Verify a clean checkout with npm ci and keep any install options the lockfile depends on. Check the resolved framework and plugin versions so an unrelated dependency update does not obscure a regression. npm clean install reference

Migration notes for Vite config

Search your config and build scripts for rollupOptions, esbuild, commonjsOptions, manualChunks and package-specific aliases. Migrate the settings you actually use. Start with the setting that explains a failed check so the diff stays easy to review.

Quick decision table

If the Vite 7 app relies onChange to try in Vite 8Check before you merge
Custom inputs or output pathsMove compatible settings from build.rollupOptions to build.rolldownOptions. For a worker bundle, move them from worker.rollupOptions to worker.rolldownOptions.Load the built entries from the production public path.
A Vite plugin that transforms worker codeKeep the plugin in the worker.plugins factory and return fresh plugin instances for each worker build. Vite worker optionsStart the worker from the production build and check the value its transform produces.
esbuild options or an optimizer pluginReview oxc for source transforms and optimizeDeps.rolldownOptions for dependency pre-bundling. The optimizer's esbuild plugin conversion is partial.Run Vite with --force and open a page that imports the affected dependency. Also run the production build.
build.commonjsOptions to make a dependency loadThat option has no effect in Vite 8. Exercise the same import and check the dependency's available ESM entry or the shape of its CommonJS export.Check the import in development, the built browser app and the built server wherever it is used.
An object in output.manualChunksTry automatic splitting first. For a required chunk group, configure output.codeSplitting.groups. Function-form manualChunks is deprecated too.Open the lazy route directly and through client navigation. Check side effects, preload links and asset size budgets.
The default browser targetPin the browser targets you still support. The defaults moved from Chrome and Edge 107 to 111, Firefox 104 to 114 and Safari 16.0 to 16.4.Run your oldest supported browser against the built app.

Check the option mappings before you move custom settings. If you restore explicit chunk groups, check how they affect module evaluation order. Vite migration guide · Rolldown chunking guide

This config keeps an existing /portal/ base and lazy-chunk filename pattern. It pins the old browser targets for an app that still supports them. Keep your actual values when you apply the same edit.

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

export default defineConfig({
  plugins: [react()],
  base: '/portal/',
  build: {
    manifest: true,
    target: ['chrome107', 'edge107', 'firefox104', 'safari16'],
    rolldownOptions: {
      output: { chunkFileNames: 'assets/lazy-[name]-[hash].js' },
    },
  },
})

For Vue, import vue from @vitejs/plugin-vue and use vue() in the plugin array. A backend that builds its own HTML should read .vite/manifest.json from the client output when it writes stylesheet, script and preload URLs. When layout changes only in production, check the emitted stylesheet too. Vite 8 uses Lightning CSS for CSS minification by default. Backend asset integration

Keep framework and custom plugin changes small

React. Keep a compatible @vitejs/plugin-react v5 release for the Vite change if your config passes Babel options to react(). The plugin's v6 release removed that option. When you upgrade the plugin, move the required Babel transforms to @rolldown/plugin-babel and verify a file that depends on them. If you use @vitejs/plugin-react-swc for an SWC plugin, confirm its Vite peer range and exercise the SWC transform before changing either tool. Open a stateful component in dev and edit its text to check Fast Refresh. React plugin changelog

Vue. Check both peer ranges for the installed @vitejs/plugin-vue release. Keep the existing Vue runtime when the plugin supports it. Exercise a single-file component with scoped CSS, a TypeScript script block and any custom block your app uses. Edit the template and the style separately to check hot updates. If the app has Vue JSX, check @vitejs/plugin-vue-jsx separately and run a component that uses its transforms. Vue plugin changelog

Custom plugins. Give each critical hook a file or output it has to handle. For a loader that emits JavaScript from another file type, check whether it needs to return moduleType: 'js'. If a build hook adds a file by assigning a property on bundle, switch to this.emitFile() and have CI assert the file exists in the output directory. Test development hooks through the dev server and build hooks with a real production build. Vite plugin API

Run the built SSR entry

Use your framework's production build command if it owns the SSR pipeline. For a custom Vite server, build client and server output separately. The fixture uses vite build --outDir dist/client --ssrManifest for browser assets and vite build --ssr src/entry-server.ts --outDir dist/server for the server entry. Start your app server with the emitted entry and serve the matching client directory under the real base path. If you use SSR preload hints, read .vite/ssr-manifest.json from the client output to look up the browser assets for rendered modules. Vite SSR build guide

If an import works during development and fails in production, inspect the built server file. For an external dependency, check what the deployment runtime installs and resolves. If the package needs a Vite transform, try adding just that dependency to ssr.noExternal and rerun the built server. Vite 8 can preserve require() calls to external packages in ESM output, and the default import shape for some CommonJS packages can change. Check the failing import under the production runtime before adding an alias or changing what gets bundled. Match any custom external export conditions in the Node process that starts the server. SSR resolution options

Request the lazy route from a fresh browser session. Check the server HTML, the styles and the interaction that requires hydration. Then navigate there from inside the app. Both paths should load every browser asset they request, including the deferred chunk. Use the actual server or hosting adapter for this check. A static preview only exercises the client build.

What passed in the test apps

The config ran on Vite 8.4.1 in a React app with a TSX component and a Vue app with a typed single-file component. Both used CSS, a lazy import and a minimal server renderer. The baseline was Vite 7.3.8 with build.rollupOptions. The framework plugins stayed fixed. Vite 7 changelog · Vite 8 changelog

The client builds produced manifests pointing to the entry, CSS and lazy chunk. The entry and lazy filenames changed hashes, and the new references under /portal/ matched files in the output. The SSR preload manifest mapped the lazy module to its emitted browser file. Development SSR and the built server entry rendered the expected heading. The fixture covered transforms, manifest references and Node rendering. Run browser hydration, HMR and custom plugin checks in your own app.

Switch CI after the release checks pass

Run the clean install, type checks and existing test suite with the same runtime and production settings used in the baseline. Build from scratch once without a restored build cache. Then key dependency and build caches by the lockfile, Node version and runner platform, plus any config or build mode that changes the output. Have CI verify that the emitted manifest resolves to files in the artifact before publishing it. Inspect any differences in entry size and lazy loading against your existing budget.

Promote the new artifact after the plugin checks, supported browsers, direct route request and hydration pass in staging. For a client-only app, verify the host's direct-route fallback and public asset path. Keep the previous release available with its HTML or SSR server, manifests and hashed assets. A rollback restores that release together. Keep referenced assets available for browsers that still hold older HTML. If CI must rebuild the previous release, restore its config, package manifest and lockfile together.

Stay on the pinned Vite 7 release if a required plugin fails, a supported browser cannot load the bundle or the production server cannot start. Reproduce the failure using one route or plugin input first. If you need to isolate the bundler swap from the other Vite 8 changes, Vite documents rolldown-vite as an intermediate test on Vite 7. Return to the full release checks before switching CI. Gradual migration notes

Source notes