Skip to content

Commit 72ff497

Browse files
authored
docs: Vite Task docs updates. (#785)
Updating docs for pending Vite Task API changes.
1 parent f13cb76 commit 72ff497

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

docs/config/run.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ Defines tasks that can be run with `vp run <task>`.
4646
### `command`
4747

4848
- **Type:** `string`
49-
- **Default:** matching `package.json` script
5049

51-
The shell command to run.
50+
Defines the shell command to run for the task.
5251

5352
```ts
5453
tasks: {
@@ -58,7 +57,7 @@ tasks: {
5857
}
5958
```
6059

61-
You cannot define a command in both `vite.config.ts` and `package.json` with the same task name.
60+
Each task defined in `vite.config.ts` must include its own `command`. You cannot define a task in both `vite.config.ts` and `package.json` with the same task name.
6261

6362
Commands joined with `&&` are automatically split into independently cached sub-tasks. See [Compound Commands](/guide/run#compound-commands).
6463

@@ -102,7 +101,7 @@ tasks: {
102101
}
103102
```
104103

105-
### `envs`
104+
### `env`
106105

107106
- **Type:** `string[]`
108107
- **Default:** `[]`
@@ -113,7 +112,7 @@ Environment variables included in the cache fingerprint. When any listed variabl
113112
tasks: {
114113
build: {
115114
command: 'vp build',
116-
envs: ['NODE_ENV'],
115+
env: ['NODE_ENV'],
117116
},
118117
}
119118
```
@@ -125,7 +124,7 @@ $ NODE_ENV=development vp run build # first run
125124
$ NODE_ENV=production vp run build # cache miss: variable changed
126125
```
127126

128-
### `passThroughEnvs`
127+
### `untrackedEnv`
129128

130129
- **Type:** `string[]`
131130
- **Default:** see below
@@ -136,7 +135,7 @@ Environment variables passed to the task process but **not** included in the cac
136135
tasks: {
137136
build: {
138137
command: 'vp build',
139-
passThroughEnvs: ['CI', 'GITHUB_ACTIONS'],
138+
untrackedEnv: ['CI', 'GITHUB_ACTIONS'],
140139
},
141140
}
142141
```
@@ -148,12 +147,12 @@ A set of common environment variables are automatically passed through to all ta
148147
- **CI/CD:** `CI`, `VERCEL_*`, `NEXT_*`
149148
- **Terminal:** `TERM`, `COLORTERM`, `FORCE_COLOR`, `NO_COLOR`
150149

151-
### `inputs`
150+
### `input`
152151

153152
- **Type:** `Array<string | { auto: boolean }>`
154153
- **Default:** `[{ auto: true }]` (auto-inferred)
155154

156-
Vite Task automatically detects which files are used by a command (see [Automatic File Tracking](/guide/cache#automatic-file-tracking)). The `inputs` option can be used to explicitly include or exclude certain files.
155+
Vite Task automatically detects which files are used by a command (see [Automatic File Tracking](/guide/cache#automatic-file-tracking)). The `input` option can be used to explicitly include or exclude certain files.
157156

158157
**Exclude files** from automatic tracking:
159158

@@ -162,7 +161,7 @@ tasks: {
162161
build: {
163162
command: 'vp build',
164163
// Use `{ auto: true }` to use automatic fingerprinting (default).
165-
inputs: [{ auto: true }, '!**/*.tsbuildinfo', '!dist/**'],
164+
input: [{ auto: true }, '!**/*.tsbuildinfo', '!dist/**'],
166165
},
167166
}
168167
```
@@ -173,7 +172,7 @@ tasks: {
173172
tasks: {
174173
build: {
175174
command: 'vp build',
176-
inputs: ['src/**/*.ts', 'vite.config.ts'],
175+
input: ['src/**/*.ts', 'vite.config.ts'],
177176
},
178177
}
179178
```
@@ -184,7 +183,7 @@ tasks: {
184183
tasks: {
185184
greet: {
186185
command: 'node greet.mjs',
187-
inputs: [],
186+
input: [],
188187
},
189188
}
190189
```

docs/guide/cache.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Vite Task can automatically track dependencies and cache tasks run through `vp r
77
When a task runs successfully (exit code 0), its terminal output (stdout/stderr) is saved. On the next run, Vite Task checks if anything changed:
88

99
1. **Arguments:** did the [additional arguments](/guide/run#additional-arguments) passed to the task change?
10-
2. **Environment variables:** did any [fingerprinted env vars](/config/run#envs) change?
10+
2. **Environment variables:** did any [fingerprinted env vars](/config/run#env) change?
1111
3. **Input files:** did any file that the command reads change?
1212

1313
If everything matches, the cached output is replayed instantly, and the command does not run.
@@ -20,13 +20,13 @@ When a cache miss occurs, Vite Task tells you exactly why:
2020

2121
```
2222
$ vp lint ✗ cache miss: 'src/utils.ts' modified, executing
23-
$ vp build ✗ cache miss: envs changed, executing
23+
$ vp build ✗ cache miss: env changed, executing
2424
$ vp test ✗ cache miss: args changed, executing
2525
```
2626

2727
## When Is Caching Enabled?
2828

29-
A command run by `vp run` is either a **task** (has an entry in `vite.config.ts`) or a **script** (only exists in `package.json` with no corresponding task entry). By default, **tasks are cached and scripts are not.**
29+
A command run by `vp run` is either a **task** defined in `vite.config.ts` or a **script** defined in `package.json`. Task names and script names cannot overlap. By default, **tasks are cached and scripts are not.**
3030

3131
There are three types of controls for task caching, in order:
3232

@@ -42,10 +42,10 @@ A task can set [`cache: false`](/config/run#cache) to opt out. This cannot be ov
4242

4343
The [`run.cache`](/config/run#run-cache) option in your root `vite.config.ts` controls the default for each category:
4444

45-
| Setting | Default | Effect |
46-
| --------------- | ------- | ------------------------------------- |
47-
| `cache.tasks` | `true` | Cache commands that have a task entry |
48-
| `cache.scripts` | `false` | Cache plain `package.json` scripts |
45+
| Setting | Default | Effect |
46+
| --------------- | ------- | --------------------------------------- |
47+
| `cache.tasks` | `true` | Cache tasks defined in `vite.config.ts` |
48+
| `cache.scripts` | `false` | Cache `package.json` scripts |
4949

5050
## Automatic File Tracking
5151

@@ -63,13 +63,13 @@ Automatic tracking can sometimes include more files than necessary, causing unne
6363
- **Tool cache files:** some tools maintain their own cache, such as TypeScript's `.tsbuildinfo` or Cargo's `target/`. These files may change between runs even when your source code has not, causing unnecessary cache invalidation.
6464
- **Directory listings:** when a command scans a directory, such as when globbing for `**/*.js`, Vite Task sees the directory read but not the glob pattern. Any file added or removed in that directory, even unrelated ones, invalidates the cache.
6565

66-
Use the [`inputs`](/config/run#inputs) option to exclude files or to replace automatic tracking with explicit file patterns:
66+
Use the [`input`](/config/run#input) option to exclude files or to replace automatic tracking with explicit file patterns:
6767

6868
```ts
6969
tasks: {
7070
build: {
7171
command: 'tsc',
72-
inputs: [{ auto: true }, '!**/*.tsbuildinfo'],
72+
input: [{ auto: true }, '!**/*.tsbuildinfo'],
7373
},
7474
}
7575
```
@@ -78,20 +78,20 @@ tasks: {
7878

7979
By default, tasks run in a clean environment. Only a small set of common variables, such as `PATH`, `HOME`, and `CI`, are passed through. Other environment variables are neither visible to the task nor included in the cache fingerprint.
8080

81-
To add an environment variable to the cache key, add it to [`envs`](/config/run#envs). Changing its value then invalidates the cache:
81+
To add an environment variable to the cache key, add it to [`env`](/config/run#env). Changing its value then invalidates the cache:
8282

8383
```ts
8484
tasks: {
8585
build: {
8686
command: 'webpack --mode production',
87-
envs: ['NODE_ENV'],
87+
env: ['NODE_ENV'],
8888
},
8989
}
9090
```
9191

92-
To pass a variable to the task **without** affecting cache behavior, use [`passThroughEnvs`](/config/run#pass-through-envs). This is useful for variables like `CI` or `GITHUB_ACTIONS` that should be available in the task, but do not generally affect caching behavior.
92+
To pass a variable to the task **without** affecting cache behavior, use [`untrackedEnv`](/config/run#untracked-env). This is useful for variables like `CI` or `GITHUB_ACTIONS` that should be available in the task, but do not generally affect caching behavior.
9393

94-
See [Run Config](/config/run#envs) for details on wildcard patterns and the full list of automatically passed-through variables.
94+
See [Run Config](/config/run#env) for details on wildcard patterns and the full list of automatically passed-through variables.
9595

9696
## Cache Sharing
9797

docs/guide/run.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ export default defineConfig({
7474
run: {
7575
tasks: {
7676
build: {
77+
command: 'vp build',
7778
dependsOn: ['lint'],
78-
envs: ['NODE_ENV'],
79+
env: ['NODE_ENV'],
7980
},
8081
deploy: {
8182
command: 'deploy-script --prod',
@@ -87,10 +88,10 @@ export default defineConfig({
8788
});
8889
```
8990

90-
If `command` is omitted, the task uses the matching script from `package.json`. A task name can come from `vite.config.ts` or `package.json`, but not both.
91+
If you want to run an existing `package.json` script as-is, use `vp run <script>`. If you want task-level caching, dependencies, or environment/input controls, define a task with an explicit `command`. A task name can come from `vite.config.ts` or `package.json`, but not both.
9192

9293
::: info
93-
Tasks defined in `vite.config.ts` are cached by default. Plain `package.json` scripts without a matching task entry are not. See [When Is Caching Enabled?](/guide/cache#when-is-caching-enabled) for the full resolution order.
94+
Tasks defined in `vite.config.ts` are cached by default. `package.json` scripts are not. See [When Is Caching Enabled?](/guide/cache#when-is-caching-enabled) for the full resolution order.
9495
:::
9596

9697
See [Run Config](/config/run) for the full `run` block reference.

0 commit comments

Comments
 (0)