You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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.
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). Theroot
is left as default, which results in it being the directory which contains the Vite config, which issrc
. ThepublicDir
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.10
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: