laravelvitelaravel-vite

Vite only importing some of the files in a folder


I'm migrating my Laravel app to Vite, and one of the things I wanted to do is copy over my images assets to the public folder. Following the Laravel doc https://laravel.com/docs/9.x/vite#blade-processing-static-assets I added import.meta.glob('../images/**'); to my app.js file, and ran the build command.

images

As you can see there are seven images in the folder. But the command outputted only 3 of them as imported, and sure enough when reloading one of the not imported images was missing : Unable to locate file in Vite manifest: images/local_icon.png.

did I miss something?


Solution

  • So what I ended up doing for now is creating a npm script "cpimages" : "rm -rf ./public/assets/images; cp -r ./resources/images ./public/assets" that I call when building "build": "npm run cpimages; vite build". My assets are available in my project, but not versionned by Vite. I can't think of anything else... If you guys got an idea please let me know.