Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Configure and optimize Turborepo monorepo build pipelines with correct task structure, caching, and CI setup.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/configuration/tasks.md
1# Task Configuration Reference23Full docs: https://turborepo.dev/docs/reference/configuration#tasks45## dependsOn67Controls task execution order.89```json10{11"tasks": {12"build": {13"dependsOn": [14"^build", // Dependencies' build tasks first15"codegen", // Same package's codegen task first16"shared#build" // Specific package's build task17]18}19}20}21```2223| Syntax | Meaning |24| ---------- | ------------------------------------ |25| `^task` | Run `task` in all dependencies first |26| `task` | Run `task` in same package first |27| `pkg#task` | Run specific package's task first |2829The `^` prefix is crucial - without it, you're referencing the same package.3031### Transit Nodes for Parallel Tasks3233For tasks like `lint` and `check-types` that can run in parallel but need dependency-aware caching:3435```json36{37"tasks": {38"transit": { "dependsOn": ["^transit"] },39"lint": { "dependsOn": ["transit"] },40"check-types": { "dependsOn": ["transit"] }41}42}43```4445**DO NOT use `dependsOn: ["^lint"]`** - this forces sequential execution.46**DO NOT use `dependsOn: []`** - this breaks cache invalidation.4748The `transit` task creates dependency relationships without running anything (no matching script), so tasks run in parallel with correct caching.4950## outputs5152Glob patterns for files to cache. **If omitted, nothing is cached.**5354```json55{56"tasks": {57"build": {58"outputs": ["dist/**", "build/**"]59}60}61}62```6364**Framework examples:**6566```json67// Next.js68"outputs": [".next/**", "!.next/cache/**"]6970// Vite71"outputs": ["dist/**"]7273// TypeScript (tsc)74"outputs": ["dist/**", "*.tsbuildinfo"]7576// No file outputs (lint, typecheck)77"outputs": []78```7980Use `!` prefix to exclude patterns from caching.8182## inputs8384Files considered when calculating task hash. Defaults to all tracked files in package.8586```json87{88"tasks": {89"test": {90"inputs": ["src/**", "tests/**", "vitest.config.ts"]91}92}93}94```9596**Special values:**9798| Value | Meaning |99| --------------------- | --------------------------------------- |100| `$TURBO_DEFAULT$` | Include default inputs, then add/remove |101| `$TURBO_ROOT$/<path>` | Reference files from repo root |102103```json104{105"tasks": {106"build": {107"inputs": [108"$TURBO_DEFAULT$",109"!README.md",110"$TURBO_ROOT$/tsconfig.base.json"111]112}113}114}115```116117### Interaction with `global.inputs`118119When `futureFlags.globalConfiguration` is enabled, files listed in `global.inputs` are prepended to every task's `inputs`. The combined list is then used to compute the task hash.120121This is different from `globalDependencies`, where files were hashed into the **global** hash and could not be influenced by task-level `inputs`.122123**With `globalDependencies` (old behavior):**124125- `globalDependencies` files contribute to the global hash126- Task `inputs` only control which **package** files are hashed127- There is no way for a task to "opt out" of a `globalDependencies` file128129**With `global.inputs` (new behavior):**130131- `global.inputs` files are merged into each task's `inputs` globs132- Task `inputs` and `global.inputs` are combined, then the full list is hashed into the **task** hash133- Tasks can exclude specific global files with negation globs134135```json136{137"futureFlags": { "globalConfiguration": true },138"global": {139"inputs": ["tsconfig.json", ".env"]140},141"tasks": {142"build": {},143"lint": {144"inputs": ["$TURBO_DEFAULT$", "!$TURBO_ROOT$/.env"]145}146}147}148```149150In this example:151152- `build` hashes all package files + `tsconfig.json` + `.env` (from `global.inputs`)153- `lint` hashes all package files + `tsconfig.json`, but **excludes** `.env` because of the negation glob154155Tasks with no explicit `inputs` key still hash all package files (the default behavior) plus the `global.inputs` files.156157## env158159Environment variables to include in task hash.160161```json162{163"tasks": {164"build": {165"env": [166"API_URL",167"NEXT_PUBLIC_*", // Wildcard matching168"!DEBUG" // Exclude from hash169]170}171}172}173```174175Variables listed here affect cache hits - changing the value invalidates cache.176177## cache178179Enable/disable caching for a task. Default: `true`.180181```json182{183"tasks": {184"dev": { "cache": false },185"deploy": { "cache": false }186}187}188```189190Disable for: dev servers, deploy commands, tasks with side effects.191192## persistent193194Mark long-running tasks that don't exit. Default: `false`.195196```json197{198"tasks": {199"dev": {200"cache": false,201"persistent": true202}203}204}205```206207Required for dev servers - without it, dependent tasks wait forever.208209## interactive210211Allow task to receive stdin input. Default: `false`.212213```json214{215"tasks": {216"login": {217"cache": false,218"interactive": true219}220}221}222```223224## outputLogs225226Control when logs are shown. Options: `full`, `hash-only`, `new-only`, `errors-only`, `none`.227228```json229{230"tasks": {231"build": {232"outputLogs": "new-only" // Only show logs on cache miss233}234}235}236```237238## with239240Run tasks alongside this task. For long-running tasks that need runtime dependencies.241242```json243{244"tasks": {245"dev": {246"with": ["api#dev"],247"persistent": true,248"cache": false249}250}251}252```253254Unlike `dependsOn`, `with` runs tasks concurrently (not sequentially). Use for dev servers that need other services running.255256## interruptible257258Allow `turbo watch` to restart the task on changes. Default: `false`.259260```json261{262"tasks": {263"dev": {264"persistent": true,265"interruptible": true,266"cache": false267}268}269}270```271272Use for dev servers that don't automatically detect dependency changes.273274## description275276Human-readable description of the task.277278```json279{280"tasks": {281"build": {282"description": "Compiles the application for production deployment"283}284}285}286```287288For documentation only - doesn't affect execution or caching.289290## passThroughEnv291292Environment variables available at runtime but NOT included in cache hash.293294```json295{296"tasks": {297"build": {298"passThroughEnv": ["AWS_SECRET_KEY", "GITHUB_TOKEN"]299}300}301}302```303304**Warning**: Changes to these vars won't cause cache misses. Use `env` if changes should invalidate cache.305306## extends (Package Configuration only)307308Control task inheritance in Package Configurations.309310```json311// packages/ui/turbo.json312{313"extends": ["//"],314"tasks": {315"lint": {316"extends": false // Exclude from this package317}318}319}320```321322| Value | Behavior |323| ---------------- | -------------------------------------------------------------- |324| `true` (default) | Inherit from root turbo.json |325| `false` | Exclude task from package, or define fresh without inheritance |326