Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vitejs | Uncaught Error: Dynamic require of "<path>.svg" is not supported

Tags:

reactjs

vite

I'm trying to use react-flagpack in my project that uses Vite, but whenever I use it i get the following error:

Uncaught Error: Dynamic require of "node_modules/flagpack-core/dist/flags/cDBuMQWP.svg" is not supported

Is this an issue with Vite? or am I doing something wrong.

Thanks in advance!

like image 731
Daniel Medina Avatar asked Sep 07 '25 04:09

Daniel Medina


2 Answers

As of June 14th 2021 it's now supported. :3

like image 149
Daniel Medina Avatar answered Sep 09 '25 19:09

Daniel Medina


Can you use this :

npm i --save @originjs/vite-plugin-require-context

Then Add ViteRequireContext into vit.config.js :

import ViteRequireContext from "@originjs/vite-plugin-require-context";
export default defineConfig(() => {  
   plugins: [
        ViteRequireContext(),
    ],
}
like image 39
Mohammad Imani Avatar answered Sep 09 '25 19:09

Mohammad Imani