Skip to content

@nx/vite - Migrations

For an overview of the plugin and setup instructions, see the @nx/vite introduction.

The @nx/vite plugin provides various migrations to help you migrate to newer versions of vite projects within your Nx workspace. Below is a complete reference for all available migrations.

Version: 24.0.0-beta.3

Converts targets using the removed @nx/vite executors, and @nx/vitest:test targets, to inferred tasks; an AI prompt finishes the targets the converter cannot convert safely and validates the project graph.

Convert @nx/vite and @nx/vitest:test targets to inferred tasks

Section titled “Convert @nx/vite and @nx/vitest:test targets to inferred tasks”

Nx 24 removes the @nx/vite:build, @nx/vite:dev-server and @nx/vite:preview-server executors and their @nrwl aliases. The migration registers @nx/vite/plugin in nx.json and converts the targets that use those executors to inferred tasks. It moves build options into vite.config.*. It also converts @nx/vitest:test targets with the @nx/vitest converter, because @nx/vitest can be installed only as a transitive dependency and its own migration may not run. A target with nothing left to override is removed from project configuration. When several projects share the same remaining options, those options move to a targetDefaults entry scoped to the plugin. targetDefaults entries keyed by a removed executor are removed once no target uses that executor.

The migration lists the targets the converter cannot convert safely. In agentic runs, an AI prompt finishes them and validates the project graph.

The serve and preview targets have no options that differ from the inferred targets, so they are removed.

myapp/project.json
{
"name": "myapp",
"targets": {
"build": {
"executor": "@nx/vite:build",
"outputs": ["{workspaceRoot}/dist/myapp"],
"options": {
"configFile": "myapp/vite.config.ts"
}
},
"serve": {
"executor": "@nx/vite:dev-server",
"options": {
"buildTarget": "myapp:build"
}
},
"preview": {
"executor": "@nx/vite:preview-server",
"options": {
"buildTarget": "myapp:build"
}
}
}
}
myapp/project.json
{
"name": "myapp",
"targets": {
"build": {
"options": {
"config": "./vite.config.ts"
}
}
}
}
nx.json
{
"plugins": [
{
"plugin": "@nx/vite/plugin",
"options": {
"buildTargetName": "build",
"devTargetName": "dev",
"previewTargetName": "preview",
"serveStaticTargetName": "serve-static",
"serveTargetName": "serve",
"typecheckTargetName": "typecheck"
}
}
]
}

Version: 24.0.0-beta.3

Replace nxViteTsPaths with Vite’s native resolve.tsconfigPaths, then migrate the remaining deprecated vite configuration helpers while preserving custom behavior.

update-24-0-0-register-typescript-plugin-for-typecheck

Section titled “update-24-0-0-register-typescript-plugin-for-typecheck”

Version: 24.0.0-beta.3

Register @nx/js/typescript with its typecheck target in workspaces that use @nx/vite/plugin without it, since @nx/vite/plugin no longer infers typecheck targets except for Vue projects.

Register @nx/js/typescript for typecheck targets

Section titled “Register @nx/js/typescript for typecheck targets”

@nx/vite/plugin no longer infers a typecheck target, except for Vue projects, which keep their vue-tsc target. @nx/js/typescript provides the typecheck target instead, in all workspaces. This migration registers @nx/js/typescript with only its typecheck target when the workspace uses @nx/vite/plugin and doesn’t register @nx/js/typescript yet, so your projects keep a typecheck target.

The new registration reuses the plugin’s typecheckTargetName and, when it’s tsgo, its compiler. Registrations with typecheckTargetName: false are skipped. @nx/js/typescript is registered before @nx/vite/plugin, so the Vue projects’ vue-tsc target wins. Keep that order.

nx.json
{
"plugins": [
{
"plugin": "@nx/vite/plugin",
"options": { "typecheckTargetName": "typecheck" }
}
]
}
nx.json
{
"plugins": [
{
"plugin": "@nx/js/typescript",
"options": { "typecheck": { "targetName": "typecheck" } }
},
{
"plugin": "@nx/vite/plugin",
"options": { "typecheckTargetName": "typecheck" }
}
]
}

Version: 24.0.0-beta.5

Add the nxReadySignal() plugin to the Vite configs of application projects, so that @nx/vite/plugin infers readyWhen: { signal: true } for their dev and preview targets; an AI prompt finishes the configs the codemod cannot edit safely.

Add the nxReadySignal() plugin to Vite configs

Section titled “Add the nxReadySignal() plugin to Vite configs”

@nx/vite/plugin infers readyWhen: { signal: true } for the dev and preview targets of a project whose Vite config loads the nxReadySignal() plugin. The plugin reports the server’s address to Nx once it listens, so a task that depends on the server with waitFor: 'ready' starts when the server accepts requests. Without the plugin, the inferred check resolves the config when the task runs and waits for the configured port, which can pass early when Vite moves to another port.

This migration adds the import and nxReadySignal() to the plugins of the vite.config.{ts,mts,cts,js,mjs,cjs} file in each project root. It skips vitest.config.* files, projectType: 'library' projects, configs with build.lib and no server options, and configs that already load the plugin. It edits a config that exports a plain object, with or without defineConfig, and a factory that returns one, such as defineConfig(() => ({ ... })) or a function body with a single return. A config it can’t edit safely, such as a mergeConfig call, a config imported from a shared base, or a plugins array that spreads plugins from elsewhere, is left alone and listed. In agentic runs, an AI prompt finishes those configs.

apps/myapp/vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig(() => ({
root: import.meta.dirname,
plugins: [react()],
}));
apps/myapp/vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { nxReadySignal } from '@nx/vite/plugins/nx-ready-signal.plugin';
export default defineConfig(() => ({
root: import.meta.dirname,
plugins: [react(), nxReadySignal()],
}));

Version: 23.0.0-beta.10

Safety net: ensure any remaining @nx/vite:test executor usages are swapped to @nx/vitest:test and @nx/vitest is installed.

Migration that runs automatically when upgrading to Nx 23. It is a safety net for workspaces that still have @nx/vite vitest artifacts in place after the optional v22 migration.

  1. Installs @nx/vitest: added to devDependencies when vitest is detected in the workspace (skipped when already present or when the workspace does not use vitest at all).
  2. Swaps @nx/vite:test to @nx/vitest:test: updates every project.json target and every targetDefaults entry that still references the removed executor.
  3. Splits @nx/vite/plugin registrations: vitest-related options (testTargetName, ciTargetName, ciGroupName) are extracted from each @nx/vite/plugin entry and moved to a new @nx/vitest plugin entry. The vite entry is updated to retain only build/serve/preview options.
  4. Registers @nx/vitest plugin: for workspaces that used @nx/vite/plugin in its default configuration (no vitest options), a matching @nx/vitest plugin entry is added automatically so vitest targets continue to be inferred.

The vitest support that previously lived in @nx/vite (the @nx/vite:test executor, the @nx/vite:vitest generator, and the vitest target inference in @nx/vite/plugin) was removed in Nx 23 and is now exclusively provided by the @nx/vitest package. See the Migrating from @nx/vite guide.

Run nx migrate and this migration will handle the conversion automatically. To verify the result, check nx.json, your project.json files, and package.json after running migrations.

Version: 23.0.0-beta.10

Rename rollupOptions to rolldownOptions in vite config files (top-level and inside environments). Vite 8 replaced Rollup with Rolldown.

NameVersion
vite>=8.0.0

Rename rollupOptions to rolldownOptions in Vite Config Files

Section titled “Rename rollupOptions to rolldownOptions in Vite Config Files”

Renames the rollupOptions property to rolldownOptions inside vite.config.{js,ts,mjs,mts,cjs,cts} files. Vite 8 replaced Rollup with Rolldown as its production bundler; rollupOptions is accepted as a deprecated alias but logs a warning and may produce precedence surprises when both keys are present. The migration covers top-level usage as well as nested environments.<env>.build.rollupOptions.

The migration only touches files matching vite.*config*.{js,ts,mjs,mts,cjs,cts}. Helper modules imported by your config and rollupOptions declared elsewhere need to be renamed by hand.

Top-level rename inside build.

apps/myapp/vite.config.ts
export default defineConfig({
build: {
rollupOptions: {
external: ['react'],
},
},
});
apps/myapp/vite.config.ts
export default defineConfig({
build: {
rolldownOptions: {
external: ['react'],
},
},
});

The same rename applies inside environments.<env>.build.

apps/myapp/vite.config.ts
export default defineConfig({
environments: {
ssr: {
build: {
rollupOptions: { external: ['fs'] },
},
},
},
});
apps/myapp/vite.config.ts
export default defineConfig({
environments: {
ssr: {
build: {
rolldownOptions: { external: ['fs'] },
},
},
},
});

Note: Rolldown is largely Rollup-compatible but a handful of options have different semantics. The most common one to check after this migration: output.manualChunks only accepts a function in Rolldown (the object-of-globs form is invalid). See tools/ai-migrations/MIGRATE_VITE_8.md (created by a sibling migration) for the full Vite 8 upgrade checklist.

Version: 23.0.0-beta.10

Create AI Instructions to help migrate users workspaces past breaking changes for Vite 8.

NameVersion
vite>=8.0.0

Version: 23.0.0-beta.22

Migrate workspaces past breaking changes for Vitest 3.

NameVersion
vitest>=3.0.0

Version: 23.0.0-beta.22

Migrate workspaces past breaking changes for Vitest 4.

NameVersion
vitest>=4.0.0

update-23-0-0-migrate-create-nodes-v2-import

Section titled “update-23-0-0-migrate-create-nodes-v2-import”

Version: 23.0.0-beta.24

Rename imports of createNodesV2 from @nx/vite/plugin to the canonical createNodes export.

Rename createNodesV2 imports to createNodes

Section titled “Rename createNodesV2 imports to createNodes”

@nx/vite renamed its primary inferred-plugin export from createNodesV2 to createNodes. The createNodesV2 name is preserved as a deprecated alias for now, but new code should use createNodes.

This migration scans every .ts, .tsx, .cts, and .mts file in your workspace and rewrites named imports and re-exports of createNodesV2 from @nx/vite/plugin to createNodes.

import { createNodesV2 } from '@nx/vite/plugin';
import { createNodes } from '@nx/vite/plugin';

Aliases are preserved (createNodesV2 as cn becomes createNodes as cn), and if a file already imports both names ({ createNodes, createNodesV2 }) the redundant binding is dropped.

Only static import/export named bindings from @nx/vite/plugin are rewritten. Namespace imports, dynamic import(...), require(...) destructuring, and property access such as plugin.createNodesV2 are left untouched — they keep working through the createNodesV2 runtime alias. Update those by hand if you want to drop the deprecated name everywhere.

Version: 23.0.0-beta.10

The following packages will be updated:

NameVersionAlways add to package.json
vite^8.0.0Updated only
@vitejs/plugin-react^6.0.0Updated only

Version: 23.0.0-beta.22

The following packages will be updated:

NameVersionAlways add to package.json
vitest^3.0.0Updated only
@vitest/coverage-v8^3.0.0Updated only
@vitest/coverage-istanbul^3.0.0Updated only
@vitest/ui^3.0.0Updated only

Version: 23.0.0-beta.22

The following packages will be updated:

NameVersionAlways add to package.json
vitest^4.0.0Updated only
@vitest/coverage-v8^4.0.0Updated only
@vitest/coverage-istanbul^4.0.0Updated only
@vitest/ui^4.0.0Updated only

Version: 22.2.0-beta.1

Create AI Instructions to help migrate users workspaces past breaking changes for Vitest 4.

NameVersion
vitest>=4.0.0

Version: 22.2.0-beta.2

Migrate Vitest usage from @nx/vite to @nx/vitest package.

Version: 22.2.0-beta.1

The following packages will be updated:

NameVersionAlways add to package.json
vitest^4.0.0Updated only
@vitest/coverage-v8^4.0.0Updated only
@vitest/coverage-istanbul^4.0.0Updated only
@vitest/ui^4.0.0Updated only

Version: 22.2.0-beta.3

The following packages will be updated:

NameVersionAlways add to package.json
@analogjs/vite-plugin-angular~2.1.2Updated only

22.2.0-analog-vitest-angular-package-updates

Section titled “22.2.0-analog-vitest-angular-package-updates”

Version: 22.2.0-beta.3

The following packages will be updated:

NameVersionAlways add to package.json
@analogjs/vitest-angular~2.1.2Updated only

Version: 21.5.0-beta.0

The following packages will be updated:

NameVersionAlways add to package.json
vite^7.1.3Updated only

Version: 21.3.0-beta.3

The following packages will be updated:

NameVersionAlways add to package.json
@analogjs/vite-plugin-angular~1.19.1Updated only
@analogjs/vitest-angular~1.19.1Updated only

Version: 21.2.0-beta.3

The following packages will be updated:

NameVersionAlways add to package.json
@analogjs/vite-plugin-angular~1.17.1Updated only
@analogjs/vitest-angular~1.17.1Updated only

Version: 21.1.2-beta.0

The following packages will be updated:

NameVersionAlways add to package.json
@analogjs/vitest-angular~1.16.1Updated only