GitHub - anatawa12/add-watch-file-test-base-url: vite bug report repro project (original) (raw)
this.addWatchFile test with base url
This is a project to reproduce an issue with the this.addWatchFile method with absolute path in Vite when using a base URL.
Reproduction Steps
- Install dependencies:
- Start the Vite server:
- Open your browser and navigate to
http://localhost:5173/vite/. - You will see contents of
test.txt. - Edit
test.txtand save the file. - You should see the changes reflected in the browser after automatic reload. however, the contents are outdated.
When we removed the base URL in vite.config.js, the contents are updated correctly.
Explanation
The contents of test.txt are provided through the virtual:test-txt virtual module created by the plugin in vite.config.js. The plugin tries to invalidate cached virtual:test-txt when test.txt is changed by calling this.addWatchFile with the absolute path of test.txt. However, the vite doesn't invalidate cached virtual:test-txt if the base URL is set in vite.config.js.