Closed lisonge closed 1 year ago
how to make import.meta.globEager
work with vite-svg-loader
?
import.meta.globEager
should work just fine with vite-svg-loader
. Can you reproduce the problem in a CodeSandbox?
@jpkleemans
codesandbox not working with import.meta.globEager
https://codesandbox.io/s/funny-bartik-w5ywxn?file=/src/main.ts:44-65
reproduce source code https://github.com/lisonge/svg-loader-test.git
i expect import.meta.globEager('@/assets/svg/*.svg', { as: 'url' })
is Record<string, string>
, but i got Record<string, Module>
Thanks for your reply and demo. I see now indeed that loading as url doesn't work. I'll have to dig in to the Import Reflection syntax of import.meta.globEager
to see how to make it work. If you'd like to help by opening a PR, that is of course also very welcome!
@jpkleemans
https://github.com/vitejs/vite/blob/v2.9.13/packages/vite/src/node/importGlob.ts#L52
vite@^2 not api to get query for import.meta.globEager
vite@^3 is work with https://github.com/vitejs/vite/blob/v3.0.0-beta.4/docs/guide/features.md#custom-queries
vite3 以上是 import.meta.glob('source', { eager: true })
。 用 ts 的时候会提示 globEage 已经废弃了