Skip to content

Nx plugins add support for a tool or framework, such as Vite, Jest, Playwright, or Gradle, to your workspace. A plugin works out which files a task reads and where it writes output. Otherwise you write that configuration yourself and keep it in sync with the tool's own config. Plugins are completely optional, and you can add them incrementally, one tool at a time.

Take a Vite app with a build script. For Nx to cache it correctly, you declare its outputs yourself:

apps/web/package.json
{
"scripts": {
"build": "vite build"
},
"nx": {
"targets": {
"build": {
"outputs": ["{projectRoot}/dist"]
}
}
}
}

That outputs path repeats build.outDir from vite.config.ts, and every Vite project in the workspace repeats it again. When the two drift apart, Nx caches the wrong folder.

With the @nx/vite plugin, you can delete both the script and the target. It reads each vite.config.ts and infers build, dev, and preview tasks with outputs taken from build.outDir. Edit the Vite config and the tasks change with it.

Most plugins also ship generators to scaffold projects or add the tool to an existing one, and migrations that update the tool and its config when you upgrade. Some read files Nx doesn't understand on its own (@nx/gradle adds Gradle projects and their dependencies to the project graph).

Run nx add with the plugin package name:

Terminal window
nx add @nx/vite

nx add installs the plugin, using the version that matches your Nx version for official @nx/* plugins. It then registers the plugin in nx.json:

nx.json
{
"plugins": [
{
"plugin": "@nx/vite/plugin",
"options": {
"buildTargetName": "build",
"devTargetName": "dev",
"previewTargetName": "preview"
// ... other task names
}
}
]
}

The options set the names of the inferred tasks. To see a project's tasks and which plugin or file set each value, run nx show project <project-name> --web.

The Nx team maintains plugins for common frontend, backend, testing, and build tools, and the community publishes plugins for many others. Browse both in the plugin registry.

If no plugin covers your tool, or your organization has its own conventions, you can write a plugin.