Common Tasks

The tasks that are inferred by plugins or that you define in your project 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 have build tasks depend on the build tasks of project dependencies across the whole repository. You can set this default in the nx.json file like this:

nx.json
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 an inferred build task for every project that has a Vite configuration file with this configuration in nx.json:

nx.json
1{ 2 "plugins": [ 3 { 4 "plugin": "@nx/vite/plugin", 5 "options": { 6 "buildTargetName": "build" 7 } 8 } 9 ] 10} 11

You can also override 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 an inferred serve task for every project that has a Vite configuration file with this configuration in nx.json:

nx.json
1{ 2 "plugins": [ 3 { 4 "plugin": "@nx/vite/plugin", 5 "options": { 6 "serveTargetName": "serve" 7 } 8 } 9 ] 10} 11

You can also override 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 an inferred test task for every project that has a Vitest configuration file with this configuration in nx.json:

nx.json
1{ 2 "plugins": [ 3 { 4 "plugin": "@nx/vite/plugin", 5 "options": { 6 "testTargetName": "test" 7 } 8 } 9 ] 10} 11

You can also override 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 an inferred lint task for every project that has an ESLint configuration file with this configuration in nx.json:

nx.json
1{ 2 "plugins": [ 3 { 4 "plugin": "@nx/eslint/plugin", 5 "options": { 6 "targetName": "lint" 7 } 8 } 9 ] 10} 11

You can also override the inferred task configuration as needed.