Skip to content

Tamp Vite

Scott Singleton edited this page May 15, 2026 · 2 revisions

Tamp.Vite

Wrapper for Vite 5 AND Vitest 1 — co-located in one package because Vitest's major tracks Vite's. Per ADR 0002 the .V{Major} pin tracks the headline tool (Vite); Vitest gets a parallel facade.

using Tamp.Vite.V5;        // pulls in both Vite and Vitest classes

Full reference: https://github.com/tamp-build/tamp-vite.

Verbs — Vite

Vite.Dev(tool, s =>)              // vite dev — long-running, foreground only
Vite.BuildProject(tool, s =>)     // vite build — the canonical CI verb
Vite.Preview(tool, s =>)          // vite preview — smoke the dist locally
Vite.OptimizeDeps(tool, s =>)     // vite optimize --force
Vite.Raw(tool,)                   // escape hatch

Common flags (all verbs): --config, --mode, --base, --logLevel, --clearScreen / --no-clearScreen, --force, --debug [category], --filter.

Verbs — Vitest

Vitest.Run(tool, s =>)            // vitest run — the canonical CI invocation
Vitest.Watch(tool, s =>)          // vitest watch — interactive
Vitest.Related(tool, s => s.AddFile("src/auth.ts"))   // run tests related to changed files
Vitest.Bench(tool, s =>)
Vitest.Typecheck(tool, s =>)
Vitest.Raw(tool,)

Common flags (all verbs): --config, --root, --dir, --mode, --silent, --bail, --pool, --reporter (repeatable), --outputFile, --passWithNoTests, --logHeapUsage, --coverage, --coverage.provider, --coverage.reporter (repeatable), --coverage.reportsDirectory.

Note: there is no Vitest.List. Vitest 1.x doesn't have a list subcommand — that's 2+. If you build against a 2.x runtime you can call Vitest.Raw(tool, "list") until a .V2 sibling package ships.

Quick example — HoldFast frontend CI

[NuGetPackage("vite", UseSystemPath = true)]
readonly Tool ViteTool = null!;

[NuGetPackage("vitest", UseSystemPath = true)]
readonly Tool VitestTool = null!;

Target Build => _ => _.Executes(() =>
    Vite.BuildProject(ViteTool, s => s
        .SetMode("production")
        .SetOutDir("dist")
        .SetEmptyOutDir(true)
        .SetSourcemap("hidden")
        .SetWorkingDirectory(RootDirectory / "frontend")));

Target Test => _ => _.Executes(() =>
    Vitest.Run(VitestTool, s => s
        .SetCoverage()
        .SetCoverageProvider("v8")
        .AddCoverageReporter("text")
        .AddCoverageReporter("lcov")
        .AddReporter("default")
        .AddReporter("junit")
        .SetOutputFile("junit=./TestResults/junit.xml")
        .SetWorkingDirectory(RootDirectory / "frontend")));

See also

Settings authoring style

The example(s) above use the fluent Set*-chain shape. Every wrapper verb on this page also accepts a new XxxSettings { ... } object-init form. Both produce identical CommandPlans; the fluent shape stays canonical in docs and the tamp init template. See Build Script Authoring → Two authoring styles for the side-by-side comparison.

Clone this wiki locally