vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.15k stars 6.15k forks source link

Error: Unknown variable dynamic import: ./icons/user.svg?raw #6992

Closed Rolanddoda closed 2 years ago

Rolanddoda commented 2 years ago

Describe the bug

First, open the simple reproduction on Stackblitz. You will see that everything works there. If you run vite build && vite preview though, you will see the error:

Error: Unknown variable dynamic import: ./icons/user.svg?raw

Reproduction

https://stackblitz.com/edit/vitejs-vite-cm8srg?devtoolsheight=33&file=src/components/SvgIcon.vue

System Info

-

Used Package Manager

npm

Logs

No response

Validations

poyoho commented 2 years ago

Maybe you can try to use https://vitejs.dev/guide/features.html#glob-import to implement the same feature.

watonyweng commented 2 years ago

I turned on sourcemap option and located the following error

92F361CC-1B38-453e-A14E-486EA2C1E3FB

watonyweng commented 2 years ago

stackblitz

arggh commented 2 years ago

I'm getting the same Error: Unknown variable dynamic import with SvelteKit and vite-imagetools. In dev it works as expected, building fails.

const { default: src } = await import(`./${slug}/cover.jpg?width=672`);
braddialpad commented 2 years ago

Getting this as well.