Fork Horse repository, listed by its owner. Publisher snapshot.
packages/custom-gatekeeper/vite.config.ts
Snapshot at 34e3175
1// Vite+ per-package settings. `vitest.config.ts` beside this file is vitest's own config (vitest
2// prefers it over this one); this file exists only to declare the `build` and `test` tasks that
3// `vp run` executes.
4//
5// Both are tasks rather than package.json scripts because each reads a path it also writes, and vp
6// declines to cache such a task: `tsc` emits into `dist/`, which automatic tracking otherwise counts
7// as an input of the same package, and every `vitest run` rewrites the scratch paths below and reads
8// them back on the next run. vp forbids a task and a script sharing a name, so the `build` and
9// `test` scripts are gone -- `vp run -F custom-gatekeeper <task>` is what replaces them.
10
11// This package's own `tsc` output. Package-relative, not workspace-wide: a sibling's `dist/` may be
12// a real input via its `exports`.
13const ownDist = { pattern: '!dist/**', base: 'package' } as const
14
15// Written and read back by every vitest run, so without these almost nothing caches. Workspace-wide
16// because tracking reaches past the package that owns the task -- a sibling's scratch files would
17// otherwise sit in this package's fingerprint. See
18// cloudflare-os/scripts/vitest-task-vite-config.ts for the full accounting of each path.
19const vitestScratch = [
20 { pattern: '!**/node_modules/.vite/**', base: 'workspace' },
21 { pattern: '!**/node_modules/.vite-temp/**', base: 'workspace' },
22 // The capnweb-validate build tree, regenerated by any suite that starts a worker under
23 // @cloudflare/vitest-pool-workers. Derived from tracked sources, so dropping it loses nothing.
24 { pattern: '!**/.wrangler/**', base: 'workspace' },
25] as const
26
27export default {
28 run: {
29 tasks: {
30 build: {
31 command: 'tsc',
32 cache: {
33 input: [{ auto: true }, ownDist],
34 output: ['dist/**'],
35 },
36 },
37 test: {
38 command: 'vitest run',
39 cache: {
40 input: [{ auto: true }, ownDist, ...vitestScratch],
41 output: [{ auto: true }, ownDist, ...vitestScratch],
42 },
43 },
44 },
45 },
46}
47