Common Tasks
The tasks that areinferred by plugins or that you define in yourproject configuration can have any name that you want, but it is helpful for developers if you keep your task naming convention consistent across the projects in your repository. This way, if a developer moves from one project to another, they already know how to launch tasks for the new project. Here are some common task names that you can define for your projects.
build
This task should produce the compiled output of this project. Typically, you'll want to havebuild
tasks depend on thebuild
tasks of project dependencies across the whole repository. You can set this default in thenx.json
file like this:
1{2"targetDefaults": {3"build": {4"dependsOn": ["^build"]5 }6 }7}8
The task might use the@nx/vite,@nx/webpack or@nx/rspack plugins. Or you could have the task launch your own custom script.
Set up aninferredbuild
task for every project that has a Vite configuration file with this configuration innx.json
:
1{2"plugins": [3 {4"plugin":"@nx/vite/plugin",5"options": {6"buildTargetName":"build"7 }8 }9 ]10}11
You can alsooverride the inferred task configuration as needed.
serve
This task should run your project in a developer preview mode. The task might use the@nx/vite,@nx/webpack or@nx/rspack plugins. Or you could have the task launch your own custom script.
Set up aninferredserve
task for every project that has a Vite configuration file with this configuration innx.json
:
1{2"plugins": [3 {4"plugin":"@nx/vite/plugin",5"options": {6"serveTargetName":"serve"7 }8 }9 ]10}11
You can alsooverride the inferred task configuration as needed.
test
This task typically runs unit tests for a project. The task might use the@nx/vite or@nx/jest plugins. Or you could have the task launch your own custom script.
Set up aninferredtest
task for every project that has a Vitest configuration file with this configuration innx.json
:
1{2"plugins": [3 {4"plugin":"@nx/vite/plugin",5"options": {6"testTargetName":"test"7 }8 }9 ]10}11
You can alsooverride the inferred task configuration as needed.
lint
This task should run lint rules for a project. The task might use the@nx/eslint plugin or run your own custom script.
Set up aninferredlint
task for every project that has an ESLint configuration file with this configuration innx.json
:
1{2"plugins": [3 {4"plugin":"@nx/eslint/plugin",5"options": {6"targetName":"lint"7 }8 }9 ]10}11
You can alsooverride the inferred task configuration as needed.