ryssbowh
46
0
Mix

mix and module architecture

Posted 3 weeks ago by ryssbowh

Hi all,

Looking for advices for a problem I've been having for quite some time now, hope somebody can share some lights on this :

I'm trying to build an application that has several modules (thanks to https://nwidart.com/laravel-modules/v4/introduction) in their own folder, and themes, in their own folders too. Each of those define js and css that can be included at runtime or not (if the module/theme isn't used for that application/route). So far I had one webpack file for each module/theme and a root webpack file including them all and building the assets into the public directory, one file per module/theme, and the module/theme responsible for loading their assets at runtime. I had a command to merge all package.json and libraries were shared in the root node_modules folder.

It works ok in development but I'd like to take it a step further and automatize the thing so I can add modules/themes (through an UI or composer or whatever) without having to rebuild assets locally.

I could have my assets already compiled in each theme/module but then it would mean having the module's assets being compiled without any knowledge of other modules, it would make sense I suppose, but I loose the ability to extract whatever external libraries a module could use. What if I have 2 modules/themes that require the same external library ? this library would be loaded 2 times, it doesn't work either.

So should I look at building assets on the spot when a module is added (through php, is that possible ?). Each module would have its node dependencies copied at development in its folder. Does that sound possible/logical ? Or am I just dreaming here and I do have to load a library two times if two modules need it ? Or anything else I could look at ?

Thanks a lot for your time.

Please sign in or create an account to participate in this conversation.