ijpatricio/minglejs-demo

Multiple react/vue application in one Laravel instance?

Closed this issue · 2 comments

Hi!

Is there any possibility of having multiple applications (with separate node_modules, src, vite.config.js, etc.) in one laravel instance - and use them together as components?

Let say, I have:

  • calculator in react
  • calendar in vue

And I want to use them as components in my Laravel application via Mingle.js - but I can't use same package.json for them

Hello!

Yes, it is possible. Unfortunately I can't find a simple way so I could be of help, you'll have to explore how to achieve it.

As you may have noticed, the demo already has both Vue and React in same repo, and as well in the same page.
But indeed, they share the same package.json.

Now, having two separate package.json is also possible, but I'm not sure how that would go in Vite and vite-laravel-plugin - which takes care of the integration. I've done something like this in the past, is was still Laravel Mix and Webpack.

What is your use case? Incompatible dependencies? If what you need is just something like that, there's a simple way.

Look at the example. You could have a nested folder with another package.json.
And just import from the full path. Notice the import Vue from './node_modules/vue'

In this example, I'm able to get Vue3 (default package,json) and Vue2 in the nested folder)

(remember to take care of gitignore for node_modules)

image
image

Hey @szymekjanaczek

Not sure if you saw this already, so I ping you again.

Closing for now, I hope the reply got you going!