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

Add option to ignore public folder #3689

Closed
alejandrovrojas opened this issue Jun 6, 2021 · 2 comments
Closed

Add option to ignore public folder #3689

alejandrovrojas opened this issue Jun 6, 2021 · 2 comments

Comments

@alejandrovrojas
Copy link

Clear and concise description of the problem

Handling of the public directory is too opinionated for SSR builds, needlessly copying assets to dist despite those files being available to the server at root level.

Using a common pattern

├── public/
│   ├── favicon.svg
│   └── other_file.css
├── src/
├── server.js
└── index.html

Then linking the assets in the index.html

<link rel="icon" href="/public/favicon.svg" />
<link rel="stylesheet" href="/public/other_file.css" />

vite build will result in

a) favicon.svg and other_file.css being copied to the root level of the dist folder (default behavour)
b) favicon.svg being copied to the dist/assets folder with a hashed filename.
c) other_file.css link entry being removed from the index file.

Suggested solution

Allow option to disable copying files from the public directory, while also ignoring /public/* entries in index.html

Alternative

There is none as of now. Renaming the public directory or changing the publicDir config to a non-existent directory solves a), but not b) and c). Currently there's no way to keep the index.html links intact and avoid copying other linked files.

@yyx990803
Copy link
Member

Because that is not how you should structure a Vite SSR project. In production, you should be serving files in the dist directory, not your project root. Everything outside dist is considered source file.

@github-actions
Copy link

This issue has been locked since it has been closed for more than 14 days.

If you have found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Vite version. If you have any other comments you should join the chat at Vite Land or create a new discussion.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants