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

FlorinBotea's avatar

Modular Laravel-Vue.js App with manifests for each module

I apologize if the title is appropriate for the content of the question. My project is structured as follows:

  • resources/js: here is main bundle, holding vue.js and some core components which I want to share across all my modules
  • Modules/MyModule/resources/js: an example of a module that would add some routes to the vue.js application and use some of the core components or define its own components
  • I use Laravel mix for compiling assets

I want to separatelly run compilation for each module. But each module may require core components or libraries and I cannot duplicate them in each module bundle. I found it useful mix.extract() to avoid duplicating vue.js and other vendor libraries in each module. In this way, I would separate vendor and core components from main bundle into one separate file and do the same in each module (they would need them just in order to be compiled - npm run watch in module folder). At the end, I would just ignore core bundle from modules and include the module unique parts. It seems reasonable. The problem is that each compile is generating a manifest.js file which assemble all bundle files. If I include 2 manifest.js, they conflict somehow throwing an 'calling .call() on undefined' error, or if I don't include all files, it won't boot the application (js).

I hope I made myself clear about what I am trying to achieve. Has anyone done something similar before? What was the approach?

Thank you!

0 likes
0 replies

Please or to participate in this conversation.