Show your laravel.mix file
Oct 11, 2021
7
Level 2
Having multiple app.js
I am building a SPA with Laravel and Inertia Vue. The app has 3 roles and I want to split app.js for each role, meaning each role dashboard will have separate app.js. Maybe something like role1app.js role2app.js and role3app.js
I tried making a separate .js file but inertia/webpack is combining it in one app.js.
How can I split them?
Level 2
Okay, I got the solution. So it was Inertia who was combining it all together. I just need to split the Pages into folder structure which I did it already and then in each app.js file I have to change the following
//from this
createInertiaApp({
resolve: (name) => require(`./Pages/${name}`),
setup({ el, App, props, plugin }) {
const app = createApp({ render: () => h(App, props) })
.use(plugin)
.use(store)
.mixin({ methods: { route: window.route } })
.mount(el);
},
});
//to this
createInertiaApp({
resolve: (name) => require(`./Pages/Role1/${name}`), // changed here
setup({ el, App, props, plugin }) {
const app = createApp({ render: () => h(App, props) })
.use(plugin)
.use(store)
.mixin({ methods: { route: window.route } })
.mount(el);
},
});
2 likes
Please or to participate in this conversation.