Skip to content

vite build --watch doesn't clean up old files #22205

@michael-paulus-icev

Description

@michael-paulus-icev

Describe the bug

vite build --watch used to clean up files as it generates new hashes / updates, it no longer does that on the latest version.

Reproduction

N/A

Steps to reproduce

Run npm create vite@latest oneline -- --template react
Add "watch": "vite build --watch", to the package.json file
Run npm run watch
Modify the index.html file, you'll notice that now you have 2 index-{hash}.js files in the assets folder

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 Intel(R) Core(TM) Ultra 9 285H
    Memory: 19.42 GB / 63.43 GB
  Binaries:
    Node: 25.3.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - C:\Users\michael.paulus\AppData\Roaming\npm\yarn.CMD
    npm: 11.6.2 - C:\Program Files\nodejs\npm.CMD
    pnpm: 10.32.1 - C:\Users\michael.paulus\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (143.0.3650.139)
  npmPackages:
    @vitejs/plugin-react: ^6.0.1 => 6.0.1 
    vite: ^8.0.4 => 8.0.8

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

Labels

feat: buildp3-minor-bugAn edge case that only affects very specific usage (priority)

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions