Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build --watch on WSL not detecting changes even with usePolling #18381

Closed
7 tasks done
ColonelThirtyTwo opened this issue Oct 17, 2024 · 2 comments · Fixed by #18390
Closed
7 tasks done

build --watch on WSL not detecting changes even with usePolling #18381

ColonelThirtyTwo opened this issue Oct 17, 2024 · 2 comments · Fixed by #18390
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@ColonelThirtyTwo
Copy link

Describe the bug

I am trying to use vite build --watch in a Docker container on a Windows host. WSL does not support filesystem events, but the Vite guide mentions using the usePolling option as a workaround. However it does not work for vite --build - it does not pick up updates. The usePolling flag only seems to work for the vite server.

Reproduction

See repoduction steps

Steps to reproduce

Package.json:

{
  "scripts": {
    "watch": "vite build --watch"
  },
  "dependencies": {
    "vite": "^5.4.9"
  }
}

vite.config.mjs:

import { defineConfig } from 'vite'
export default defineConfig({
    build: {
        watch: {
            chokidar: {
                usePolling: true,
                interval: 1000,
            }
        }
    },
})

docker-compose.yml:

services:
  vite:
    image: node:21-alpine
    volumes:
      - .:/app
    command: sh -c "cd /app/ && npm install && npm run watch"

index.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>Goodbye World!</h1>
</body>
</html>

Start the container. Edit the index.html file. Observe that neither the output of the container mentions rebuilding nor does dist/index.html change in response to the edits.

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (20) x64 13th Gen Intel(R) Core(TM) i9-13900H
    Memory: 43.46 GB / 63.68 GB
  Binaries:
    Node: 22.4.1 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (128.0.2739.63)
    Internet Explorer: 11.0.22621.3527

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red
Copy link
Member

--watch was overriding the config watch option. If you call vite build instead of vite build --watch, it worked.

@sapphi-red sapphi-red added the p3-minor-bug An edge case that only affects very specific usage (priority) label Oct 18, 2024
@ColonelThirtyTwo
Copy link
Author

Interesting - I was under the impression that vite build did not watch files unless --watch was given, but you are right - running vite build with my example does watch.

Either way, thanks for the fix.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants