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

[Bug report] Can not load file without extname in public folder #1364

Closed
YunYouJun opened this issue Jan 5, 2021 · 6 comments
Closed

[Bug report] Can not load file without extname in public folder #1364

YunYouJun opened this issue Jan 5, 2021 · 6 comments

Comments

@YunYouJun
Copy link
Contributor

Describe the bug

When i upgrade vite from v1.0.0-rc.13 to v2.0.0-beta.4, i can not load file (without extname) in public folder.

For example, i can not load file called abc, but i can load the same file called abc.data.

4:01:26 PM [vite] Internal server error:
  Error: Failed to load url /weights/ssd_mobilenetv1_model-shard1. Does the file exist?
      at transformRequest (/Users/yunyou/github/lab/vtuber/node_modules/vite/dist/node/chunks/dep-d7654bd1.js:67089:15)

Reproduction

Just create a file called test and a file called test.json in public folder, then ask it.

System Info

  • required vite version: v2.0.0-beta.4
  • required Operating System: macOS 11.1
  • required Node version: v12.14.1
@Ttou
Copy link

Ttou commented Jan 5, 2021

2.0.0-beta.5 也有这个问题

@yyx990803
Copy link
Member

yyx990803 commented Jan 5, 2021

This is expected behavior. Everything in public must be referenced with explicit extensions in 2.0.

Also, files inside public should not be imported from JS. They can only be referenced via direct asset references like <img src> or <link href>.

@YunYouJun
Copy link
Contributor Author

Thank you for your answer. I read the description of vite docs.

The public Directory

If you have assets that are:

  • ...or you simply don't want to have to import an asset first just to get its URL

I use face-api.js by vite. So I put the model under public.

It is a lib needs to load some models. Because the model is too large, the model is typically split into small files and loaded through js.

For example:

.
├── ssd_mobilenetv1_model-shard1
├── ssd_mobilenetv1_model-shard2
└── ssd_mobilenetv1_model-weights_manifest.json

Should an option be provided for users to decide whether to allow access to files without extname?

@yyx990803
Copy link
Member

If the lib is trying to load extension-less files under public by XHR it should work. If you think this is a bug, you need to provide an actual reproduction.

@YunYouJun
Copy link
Contributor Author

I create a demo project vite-bug-report-1364. The detailed steps are described in the README.

@yyx990803
Copy link
Member

This is fixed in a7bca9c

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 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

3 participants