Anyone that has this issue with Nested Layouts in Vue / Inertia, this is what needs to be done:
In vite.config.js add the DefineOptions plug.
// install the npm package - npm i -D unplugin-vue-define-options @vue-macros/volar
import {defineConfig} from 'vite';
import DefineOptions from 'unplugin-vue-define-options/vite'
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
export default defineConfig({
plugins: [
// notice the DefineOptions() plugin here:
DefineOptions(),
laravel({
input: 'resources/js/app.js',
ssr: 'resources/js/ssr.js',
refresh: true,
valetTls: 'demo.test',
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
server: {
https: true,
host: 'demo.test',
}
});
Then in your Vue views that use the Nested Layout, use the following code:
<script setup>
import ForumLayout from "@/Layouts/Discussion/ForumLayout.vue";
import Layout from "@/Layouts/Layout.vue";
defineOptions({
layout: [Layout, ForumLayout],
name: "ThreadsIndex",
});
</script>
And that it! Vue will override and persistent layout setup in the app.js CreateVueApp / CreateInertiaApp section, and place the layouts as nested & defined in the the defineOptions() macro.
You can find more information about it here: https://vue-macros.sxzz.moe/macros/define-options.html