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 ci
npx 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
Describe the bug
It appears that
vite build --watchonly copies overpubliconce 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.tsprocess that does that. We expect the mainvite build --watchprocess to watch file changes inpublicjust 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 --watchpublic/fooexpected:
dist/foocontains updated contentactual:
dist/foocontains content old content from whennpx vite build --watchwas startedSystem 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.11Used Package Manager
npm
Logs
No response
Validations