I have two react projects created by create-react-app kit which both will use same database and some shared models. For backend i've created one Laravel project and in it's public directory i've put React projects :
--Laravel project
|-- app
|-- bootstarp
...
|-- public
|-- frontend (react app)
|-- panel (react app)
|-- index.php (Laravel's index)
...
|-- vendor
|-- .env
Since i'm going to use Laravel just for REST api, i've set up 3 domains like :
frontend.local
panel.frontend.local
api.frontend.local
The reason for doing this, is that i don't want to recreate database or shared models for each project and right now everything works great. I can access projects and i can send api requests too. So my question is : Is this approach good ? and if it's not, how can i have one instance of Laravel app for two react apps.
Laravel Mixand just compile two react projects? Or just keep two separate instances ofCRA.mix.react('app.jsx', 'public/js')but my react projects dont have an app.jsx and components are chunked into several js files instatic/js.The reason for doing this is to only fetch required components when user visit the app. So i think if i usemix, it would put them all into one file again, am i right ?mix.react('resources/assets/js/app.js', 'public')and inapp.jsi haverequire('./bootstrap'); require('./src/main.8707543e');This/main.8707543eis my entry point and loads other chunks when required. All other static files (chunks) are inpublic/static/. Right now everything works but i'm not sure if i'm doing it correctly. For code splitting i'm using github.com/thejameskyle/react-loadable to make my app load components on demand.