nx/docs/shared/plugin-features/create-your-own-plugin.md
2023-01-13 18:07:37 -05:00

3.6 KiB

Create Your Own Plugin

Nx is like the VSCode of build tools. The core of Nx enables project and task graph creation and analysis, orchestration and execution of tasks, computation caching, and code generation. Nx plugins extend this functionality and are built on top of the underlying Nx Devkit.

{% callout type="note" title="Plugins are optional" %} Many organizations use Nx without any plugins. If you are mainly interested in making your workspace faster or enabling distributed task execution, then plugins aren't necessary. {% /callout %}

{% cards %} {% card title="Create a Nx Generator in 100 seconds" description="Learn how to setup a new local generator in less than 2 minutes" type="video" url="https://www.youtube.com/watch?v=ubgroK5T6cA" /%} {% card title="Creating and Publishing Your Own Nx Plugin" description="Learn how to build your own Playwright" type="video" url="https://youtu.be/vVT7Al01VZc" /%} {% /cards %}

Nx plugins

Nx plugins contain executors and generators to extend the capabilities of an Nx workspace. They can be shared as npm packages or referenced directly within a single repo.

{% personas %}

{% persona type="browse" title="Browse Existing Plugins" url="/community#plugin-directory" %}

Browse through plugins built by Nx and the community.

{% /persona %}

{% persona type="create" title="Build a Plugin" url="/packages/nx-plugin" %}

Build a plugin for use in your own repo or to share with others.

{% /persona %}

{% persona type="share" title="Share Your Plugin" url="/recipes/advanced-plugins/share-your-plugin" %}

Publish your plugin to npm and keep your plugin users up to date with migration generators.

{% /persona %}

{% persona type="extend" title="Extend Core Nx Functionality" url="/recipes/advanced-plugins/project-graph-plugins" %}

Extend the Nx graph logic to understand other languages and custom setups.

{% /persona %}

{% /personas %}

All the core plugins are written using Nx Devkit, and you can use the same utilities to write your own generators and executors.

{% callout type="check" title="Plugins!" %} The Nx team maintains a core set of plugins for many application and tooling frameworks. You can write generators and executors in a plugin to use in your own repo or share it with the community. The Nx Plugin plugin provides guidance on how you can build your own custom plugins. {% /callout %}

Pay as you go

As with most things in Nx, the core of Nx Devkit is very simple. It only uses language primitives and immutable objects (the tree being the only exception). See Simplest Generator and Simplest Executor for examples on creating generators and executors. The Using Executors and Using Generators guides also have additional information on executors and generators.

Learn more