`build --watch` doesn't watch files in `public`
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 62/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- node.js, typescript
- Domain
- build-system, tooling
Research direction
Start with the linked minimal reproduction, run npm ci and npx vite build --watch, then edit public/foo and compare it with dist/foo. Trace the build-watch handling for public-directory files and add coverage showing that edits are copied to the output directory without restarting the build.
Written by the indexing model from the issue text.
Description
Describe the bug
It appears that vite build --watch only copies over public once when initialised, instead of watching them. We expect them to be watched just like other source files.
We use Vite to build a website with a service worker into a static directory, so that our custom HTTP server can pick it up. The website has a service worker and it needs different build settings than the main site. We have a separate vite build --watch --outDir=public --config=vite.sw.config.ts process that does that. We expect the main vite build --watch process to watch file changes in public just like it watches file changes from outher sources, and we expect it to sync those changes into its out dir so our custom HTTP server can pick them up.
Reproduction
https://github.com/Skn0tt/vite-build-watch-public-repro
Steps to reproduce
npm cinpx vite build --watch- edit contents of
public/foo
expected: dist/foo contains updated content
actual: dist/foo contains content old content from when npx vite build --watch was started
System Info
System:
OS: macOS 15.1
CPU: (12) arm64 Apple M3 Pro
Memory: 125.64 MB / 18.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.7.0 - ~/.nvm/versions/node/v22.7.0/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v22.7.0/bin/yarn
npm: 10.8.2 - ~/.nvm/versions/node/v22.7.0/bin/npm
pnpm: 9.6.0 - ~/.nvm/versions/node/v22.7.0/bin/pnpm
Browsers:
Chrome: 131.0.6778.70
Edge: 130.0.2849.80
Safari: 18.1
npmPackages:
vite: ^5.4.11 => 5.4.11
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
- Dominant language
- TypeScript
- Stars
- 82.9k
- Forks
- 8.8k
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 61
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vitejs/vite
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
pending triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
“native config loader incompatibilities” warning is shown even when setting a bundler explicitly Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
vercel/react-tweet#225 ·