Skip to content

Commit b15e59e

Browse files
authored
docs: add enablePrePostScripts option to run config page (#801)
1 parent 29b4d4e commit b15e59e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/config/run.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { defineConfig } from 'vite-plus';
77

88
export default defineConfig({
99
run: {
10+
enablePrePostScripts: true,
1011
cache: {
1112
/* ... */
1213
},
@@ -17,6 +18,27 @@ export default defineConfig({
1718
});
1819
```
1920

21+
## `run.enablePrePostScripts`
22+
23+
- **Type:** `boolean`
24+
- **Default:** `true`
25+
26+
Whether to automatically run `preX`/`postX` package.json scripts as lifecycle hooks when script `X` is executed.
27+
28+
When enabled (the default), running a script like `test` will automatically run `pretest` before it and `posttest` after it, if they exist in `package.json`.
29+
30+
```ts
31+
export default defineConfig({
32+
run: {
33+
enablePrePostScripts: false, // Disable pre/post lifecycle hooks
34+
},
35+
});
36+
```
37+
38+
::: warning
39+
This option can only be set in the workspace root's `vite.config.ts`. Setting it in a package's config will result in an error.
40+
:::
41+
2042
## `run.cache`
2143

2244
- **Type:** `boolean | { scripts?: boolean, tasks?: boolean }`

0 commit comments

Comments
 (0)