Skip to content

The @nx/plugin plugin provides various generators to help you create and configure plugin projects within your Nx workspace. Below is a complete reference for all available generators and their options.

create-package

Create a framework package that uses Nx CLI.

Examples

Basic executable

Create an executable that initializes an Nx workspace with {my-plugin}‘s preset:

Terminal window
nx g @nx/plugin:create-package create-my-plugin --project my-plugin

Usage:

Terminal window
nx generate @nx/plugin:create-package [options]

Arguments:

Terminal window
nx generate @nx/plugin:create-package <directory> [options]

Options

OptionTypeDescriptionDefault
--namestring [required]The package name of cli, e.g. create-framework-package. Note this must be a valid NPM name to be published.
--projectstring [required]The name of the generator project.
--compilerstringThe compiler used by the build and test targets."tsc"
--e2eProjectstringThe name of the e2e project.
--linterstringThe tool to use for running lint checks.
--skipFormatbooleanSkip formatting files.false
--tagsstringAdd tags to the library (used for linting).
--unitTestRunnerstringTest runner to use for unit tests.
--useProjectJsonbooleanUse a project.json configuration file instead of inlining the Nx configuration in the package.json file.

e2e-project

Create an E2E app for a Nx Plugin.

Examples

E2E Project

Scaffolds an E2E project for the plugin my-plugin.

Terminal window
nx g @nx/plugin:e2e-project --pluginName my-plugin --npmPackageName my-plugin --pluginOutputPath dist/my-plugin

Usage:

Terminal window
nx generate @nx/plugin:e2e-project [options]

Options

OptionTypeDescriptionDefault
--npmPackageNamestring [required]the package name of the plugin as it would be published to NPM.
--pluginNamestring [required]the project name of the plugin to be tested.
--jestConfigstringJest config file.
--linterstringThe tool to use for running lint checks.
--minimalbooleanGenerate the e2e project with a minimal setup. This would involve not generating tests for a default executor and generator.false
--pluginOutputPathstringthe output path of the plugin after it builds.
--projectDirectorystringthe directory where the plugin is placed.
--skipFormatbooleanSkip formatting files.false
--useProjectJsonbooleanUse a project.json configuration file instead of inlining the Nx configuration in the package.json file.

executor

Create an Executor for an Nx Plugin.

Examples

Basic executor

Create a new executor called build at tools/my-plugin/src/executors/build.ts:

Terminal window
nx g @nx/plugin:executor tools/my-plugin/src/executors/build.ts
Without providing the file extension

Create a new executor called build at tools/my-plugin/src/executors/build.ts:

Terminal window
nx g @nx/plugin:executor tools/my-plugin/src/executors/build
With different exported name

Create a new executor called custom at tools/my-plugin/src/executors/build.ts:

Terminal window
nx g @nx/plugin:executor tools/my-plugin/src/executors/build.ts --name=custom
With custom hashing

Create a new executor called build at tools/my-plugin/src/executors/build.ts, that uses a custom hashing function:

Terminal window
nx g @nx/plugin:executor tools/my-plugin/src/executors/build --includeHasher

Usage:

Terminal window
nx generate @nx/plugin:executor [options]

Arguments:

Terminal window
nx generate @nx/plugin:executor <path> [options]

Options

OptionTypeDescriptionDefault
--descriptionstringExecutor description.
--includeHasherbooleanShould the boilerplate for a custom hasher be generated?false
--namestringThe executor name to export in the plugin executors collection.
--skipFormatbooleanSkip formatting files.false
--skipLintChecksbooleanDo not add an eslint configuration for plugin json files.false
--unitTestRunnerstringTest runner to use for unit tests."jest"

generator

Create a Generator for an Nx Plugin.

Usage:

Terminal window
nx generate @nx/plugin:generator [options]

Arguments:

Terminal window
nx generate @nx/plugin:generator <path> [options]

Options

OptionTypeDescriptionDefault
--descriptionstringGenerator description.
--namestringThe generator name to export in the plugin generators collection.
--skipFormatbooleanDo not format files with prettier.false
--skipLintChecksbooleanDo not add an eslint configuration for plugin json files.false
--unitTestRunnerstringTest runner to use for unit tests."jest"

migration

Create a Migration for an Nx Plugin.

Usage:

Terminal window
nx generate @nx/plugin:migration [options]

Arguments:

Terminal window
nx generate @nx/plugin:migration <path> [options]

Options

OptionTypeDescriptionDefault
--packageVersionstring [required]Version to use for the migration.
--descriptionstringMigration description.
--namestringThe migration name to export in the plugin migrations collection.
--packageJsonUpdatesbooleanWhether or not to include package.json updates.false
--skipLintChecksbooleanDo not eslint configuration for plugin json files.false

plugin

Create a Plugin for Nx.

Usage:

Terminal window
nx generate @nx/plugin:plugin [options]

Arguments:

Terminal window
nx generate @nx/plugin:plugin <directory> [options]

Options

OptionTypeDescriptionDefault
--compilerstringThe compiler used by the build and test targets."tsc"
--e2eProjectDirectorystringA directory where the plugin E2E project is placed.
--e2eTestRunnerstringTest runner to use for end to end (E2E) tests."none"
--importPathstringHow the plugin will be published, like @myorg/my-awesome-plugin. Note this must be a valid NPM name.
--linterstringThe tool to use for running lint checks.
--namestringPlugin name
--publishablebooleanGenerates a boilerplate for publishing the plugin to npm.false
--setParserOptionsProjectbooleanWhether or not to configure the ESLint parserOptions.project option. We do not do this by default for lint performance reasons.false
--skipFormatbooleanSkip formatting files.false
--skipLintChecksbooleanDo not eslint configuration for plugin json files.false
--skipTsConfigbooleanDo not update tsconfig.json for development experience.false
--standaloneConfigbooleanSplit the project configuration into <projectRoot>/project.json rather than including it inside workspace.json.true
--tagsstringAdd tags to the library (used for linting).
--unitTestRunnerstringTest runner to use for unit tests.
--useProjectJsonbooleanUse a project.json configuration file instead of inlining the Nx configuration in the package.json file.

plugin-lint-checks

Adds linting configuration to validate common json files for nx plugins.

Usage:

Terminal window
nx generate @nx/plugin:plugin-lint-checks [options]

Options

OptionTypeDescriptionDefault
--projectNamestring [required]Which project should be the configuration be added to?
--skipFormatbooleanSkip formatting files with prettier.false

Getting Help

You can get help for any generator by adding the --help flag:

Terminal window
nx generate @nx/plugin:<generator> --help