Closed parrotdance closed 3 years ago
At /components/HelloWorld.vue, import the .txt file with import txt from '/a.txt' inner script tag Error shows with: Cannot find module '/a.txt' or its corresponding type declarations.Vetur(2307)
Look like it is caused by vetur
, you can open a issue with it.
it seems like vite has do many things to let users import common static assets out of box, but how can I do if I wanna do the same thing with other type of file? I didn't find any solution in README, and I wonder that will Vite provide any ways to get this through? Just like loader in Webpack?
The issues of static asssets config, you can track here https://github.com/vitejs/vite/issues/810.
@underfin Thanks a lot, now I got the right place.
Describe the bug
I was try to import something file like
.txt
, but I got some error message from Vetur.npm init vite-app myproj
/public
and create an empty.txt
file at/public/a.txt
lang="ts"
property inscript
tagtypes.d.ts
file with content below:/components/HelloWorld.vue
, import the.txt
file withimport txt from '/a.txt'
innerscript
tagCannot find module '/a.txt' or its corresponding type declarations.Vetur(2307)
Btw I write
import txt from '/a.txt'
at another.ts
file and it feels right. So, In fact, I am not sure about that this bug is about Vetur or Vite.If the problem is truely about Vite, I mean, it seems like vite has do many things to let users import common static assets out of box, but how can I do if I wanna do the same thing with other type of file? I didn't find any solution in README, and I wonder that will Vite provide any ways to get this through? Just like loader in Webpack?
Reproduction
I think I have provided enough information for this issue, it's okay with create a reproduction if we really need.
System Info
vite
version: 0.15.6vue
version (fromyarn.lock
orpackage-lock.json
) 3.0.0@vue/compiler-sfc
version 3.0.0