Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jmofacade's avatar

Vite static files best practice

Hello fellow Laravelers

I am migrating a project from Mix to Vite and am a bit stuck with what do about our self-hosted TinyMCE package. We currently use Mix's copy function to copy the whole package into the public directory: .copy('node_modules/tinymce/', 'public/js/tinymce/') In our app.blade.php, we import the tinymce.min.js file and the file, when necessary, loads the required plugins by fetching JS and CSS from the relative path of the original JS file.

Vite seems to prefer imports or using the public directory. I've tried various permutations of globs with import.meta.glob(['/node_modules/tinymce']); but it does not seem to work well for folder imports. I was hoping I could use globs and use Vite::asset(). The glob URLs come out with chunk hashes so the relative loads fail. It also seems like the folder structure is flattened when globbed.

I have something working now with Vite plugin static copy but was just wondering if there's an alternative way that is more Vite-friendly.

0 likes
0 replies

Please or to participate in this conversation.