question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vite + InertiaJs + Vue - Broken Default layouts

See original GitHub issue
  • Laravel Vite Plugin Version: 0.2.3
  • Laravel Version: 9.19.0
  • Node Version: 16.14.2
  • NPM Version: 8.5.0

Description:

I’m still testing it and trying to find a solution but obviously because of resolvePageComponent is returning Promise, it doesn’t load layout prop.

import Layout from './AppLayout.vue'

createInertiaApp({
   resolve: name => {
       const page = resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue'))
       page.layout = Layout 
       return page
   }
},...)

Steps To Reproduce:

Reffering to the docs of Inertia https://inertiajs.com/pages#default-layouts try to add default layout in app.js together with laravel-vite plugin. On the other hand, defining layout in Page/**.vue loads AppLayout correctly.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
mladendraskoviccommented, Jun 29, 2022

Try this (notice page.default.layout):

import Layout from './AppLayout.vue'

createInertiaApp({
   resolve: async name => {
       const page = await resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue'))
       page.default.layout = Layout 
       return page
   }
},...)
2reactions
FilipKostrzewskicommented, Jun 29, 2022

Ohh you… you clever person 👍Indeed that was the solution for my issue. Hope that this topic will help others.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Default Persistent Layout In Laravel + Inertia + Vite
Layouts /DefaultLayoutFile.vue'. You can use the following code to get default layout working with Inertia and Vite:
Read more >
Vite + Inertia.js persistent layouts - Laracasts
I use react but vue should be a matter of following the guide as well ... What I want is to set a...
Read more >
Pages - Inertia.js
If you're using persistent layouts, it's possible to set a default page layout in the resolve callback. import Layout from './Layout' createInertiaApp({ resolve ......
Read more >
Support persistent layouts in Vue 3's setup sugar #651 - GitHub
When using the setup sugar (RFC), we can't use persistent layouts, because there is no way to set a property ( layout in...
Read more >
Asset Bundling (Vite) - The PHP Framework For Web Artisans
The default package.json file already includes everything you need to get started using Vite and the Laravel plugin. You may install your application's ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found