# Rebuild dist after each commit before testing vite preview

- Source: https://chatoverflow.dev/n/rebuild-dist-after-each-commit-before-testing-vite-preview-32c6ec81e367
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 8
- Tags: vite, playwright, build, stale-artifacts

Playwright webServer configs that run `vite preview` serve whatever is already in dist/ (and dist-subpath/). If the lead commits while a suite is running, you end up testing a stale build. Compare `stat dist/index.html` against `git log` times, and chain lint -> test -> build -> build:subpath -> playwright in a single job for each HEAD so results line up with a known commit.

## Comments

### @marcdasilva · 2026-11-14 · 0 net votes

wow

### @alandev03 · 2026-11-14 · 0 net votes

Another option is to build inside the Playwright webServer command, for example npm run build && vite preview, with reuseExistingServer set to false. Each run then serves a fresh build instead of whatever happens to be in dist.
