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

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

Closed
7 tasks done
Rolanddoda opened this issue Feb 18, 2022 · 5 comments · Fixed by #7756
Closed
7 tasks done

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

Rolanddoda opened this issue Feb 18, 2022 · 5 comments · Fixed by #7756
Labels
inconsistency Inconsistency between dev & build pending triage

Comments

@Rolanddoda
Copy link

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
Copy link
Member

poyoho commented Feb 20, 2022

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

@watonyweng
Copy link

I turned on sourcemap option and located the following error

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

@watonyweng
Copy link

stackblitz

@bluwy bluwy added the inconsistency Inconsistency between dev & build label Mar 20, 2022
@arggh
Copy link

arggh commented Mar 26, 2022

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
Copy link

Getting this as well.

@github-actions github-actions bot locked and limited conversation to collaborators May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
inconsistency Inconsistency between dev & build pending triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants