-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Import a path from public folder by import.meta.glob has a unexpected behavior #15190
Comments
我也遇到了相同的问题,单独引入是可以的,批量引入必须带/public,而且批量引入控制台会警告,请问您解决了吗 |
I face the same problem, rn I use regex to change the path according to different env modes!
|
Yeah, encountering the same problem with |
I'm having the same problem here. As an example. The following works: const f1path = import("/fonts/aldrich-v21-latin-regular.woff2?url"); The following does not work: const fontPaths = import.meta.glob("/fonts/*.woff2", {
eager: true,
query: "?url",
import: "default",
}); However if I change
|
There is one additional problem: when building the application (as opposed to running the dev server), the generated URLs are inside the |
Description
For example, we got a file named 'bar.json' at
/public/lfs/bar.json
. We can useimport
to get the path.However, by using
import.meta.glob
:import.meta.glob('/lfs/bar.json')
will get nothing, because there is no 'bar.json' in/lfs/
, it is actually in/public/lfs/
import.meta.glob('/public/lfs/bar.json')
will get/public/lfs/bar.json
. But what we want is/lfs/bar.json
Suggested solution
None :(
Alternative
Instead of
import.meta.glob('/public/lfs/bar.json')
, usingimport.meta.glob('/lfs/bar.json')
likeimport()
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: