1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { createInertiaApp } from '@inertiajs/react'
import { createElement } from 'react'
import { createRoot } from 'react-dom/client'
import './application.css'
createInertiaApp({
// Set default page title
// see https://inertia-rails.netlify.app/guide/title-and-meta
//
// title: title => title ? `${title} - App` : 'App',
// Disable progress bar
//
// see https://inertia-rails.netlify.app/guide/progress-indicators
// progress: false,
resolve: (name) => {
const pages = import.meta.glob('../pages/**/*.jsx', {
eager: true,
})
const page = pages[`../pages/${name}.jsx`]
if (!page) {
console.error(`Missing Inertia page component: '${name}.jsx'`)
}
// To use a default layout, import the Layout component
// and use the following lines.
// see https://inertia-rails.netlify.app/guide/pages#default-layouts
//
// page.default.layout ||= (page) => createElement(Layout, null, page)
return page
},
setup({ el, App, props }) {
if (el) {
createRoot(el).render(createElement(App, props))
} else {
console.error(
'Missing root element.\n\n' +
'If you see this error, it probably means you load Inertia.js on non-Inertia pages.\n' +
'Consider moving <%= vite_javascript_tag "inertia" %> to the Inertia-specific layout instead.',
)
}
},
})