Skip to content

@nx/plugin Generators

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.

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

Create a framework package that uses Nx CLI.

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]
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.

Create an E2E app for a Nx Plugin.

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]
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.

Create an Executor for an Nx Plugin.

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

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

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

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]
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"

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]
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"

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]
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

Create a Plugin for Nx.

Usage:

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

Arguments:

Terminal window
nx generate @nx/plugin:plugin <directory> [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"
--enableTypedLintingbooleanWhether to enable typed linting. For flat configs, this configures the recommended parserOptions.projectService and tsconfigRootDir. For legacy .eslintrc configs, this configures parserOptions.project. We do not enable this by default for lint performance reasons.false
--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
--setParserOptionsProjectbooleanDeprecated alias for enableTypedLinting.false
--skipFormatbooleanSkip formatting files.false
--skipLintChecksbooleanDo not eslint configuration for plugin json files.false
--skipTsConfigbooleanDo not update tsconfig.json for development experience.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.

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

Usage:

Terminal window
nx generate @nx/plugin:plugin-lint-checks [options]
OptionTypeDescriptionDefault
--projectNamestring [required]Which project should be the configuration be added to?
--skipFormatbooleanSkip formatting files with prettier.false

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

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