Closed lighth7015 closed 2 years ago
Emm.... has some mistakes...
inertia()
is an object, not a function. and this is not to use the composer()
function, the use time is to use the installed composer package will be used it:- inertia(({ composer }) => {
- namespaces: [
- composer( 'hpprx/core', '.' ),
- composer( 'hpprx/myapp', 'Modules/Myapp' ),
- ]
- }),
+ inertia({
+ namespaces: [
+ { myapp: 'Modules/Myapp/Resources/views/pages' },
+ ],
+ }),
The namespace object is a namespace => path mapping, myapp
is the namespace and Modules/Myapp/Resources/views/pages
is the path corresponding to the namespace. You can use Inertia::render('myapp::welcome');
(welcome
is welcome.vue
component) to use the module page in the main app.
createInertiaApp({
- resolve: resolvePage(() => (
- import.meta.glob('./pages/**/*.vue')
- )),
+ resolve: resolvePage(() => {
+ return import.meta.glob('../views/pages/**/*.vue')
+ }),
This loads the main pages for the main app, but then your pages are put in resources/views/pages
, and must be changed the glob pattern to ../views/pages/**/*.vue
.
Note: Copying and pasting the code from the documentation is recommended.
Modules/Myapp/Resources/views/pages/welcome.vue
(can add to anywhere in this page, because this is only to look and welcome.vue is different):<template>
...
<span class="dark:text-white px-2 text-lg font-semibold">In plugin</span>
...
</template>
routes/web.php
:Route::get('/', function () {
return inertia('welcome'); // resources/views/pages/welcome.vue
});
Route::get('/myapp', function () {
return inertia('myapp::welcome'); // Modules/Myapp/Resources/views/pages/welcome.vue
});
Hi,
So I'm playing around with your inertia plugin, however my
vite.config.ts
doesn't seem to be building my module correctly, Am I over-thinking how this plug-in works? Probably, but that's why I figured I'd ask. :pThanks!