-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Description
Describe the bug
I keep my Vite config (also index.html, tsconfig.json, etc.) inside my src directory. Inside my Vite config, I change the working directory to __dirname (ESM polyfilled). The root is left as default, which results in it being the directory which contains the Vite config, which is src. The publicDir option is set to ../public, which is outside the root.
With the above setup, if I start the dev server, then add a file to the public directory (eg. foo.txt, then attempt to open it in the browser (eg. http://localhost:5173/foo.txt), I will be served the SPA default and not the text file I just added.
Reproduction
https://stackblitz.com/edit/vitejs-vite-wxmhrw
Steps to reproduce
Open the stackblitz. The dev server should start automatically. Add a foo.txt file to the public directory. Append /foo.txt to the preview window URL. The contents of the text file will not be displayed.
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.18.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.3 - /usr/local/bin/npm
pnpm: 8.15.3 - /usr/local/bin/pnpm
npmPackages:
vite: ^5.2.8 => 5.2.10Used 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.