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

New files added after dev start are not served if public is outside the root. #16503

Closed
7 tasks done
Shakeskeyboarde opened this issue Apr 22, 2024 · 2 comments · Fixed by #16502
Closed
7 tasks done

Comments

@Shakeskeyboarde
Copy link
Contributor

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.10

Used Package Manager

npm

Logs

No response

Validations

Copy link

stackblitz bot commented Apr 22, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@Shakeskeyboarde
Copy link
Contributor Author

I have a fix PR here #16502

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant