Sha256: 8de46290e4df451fa208e288c47acd860dabf34bcf015ba051752d5339149331

Contents?: true

Size: 955 Bytes

Versions: 3

Compression:

Stored size: 955 Bytes

Contents

import './bootstrap'
import '../../assets/builds/tailwind.css'

import { createRoot } from 'react-dom/client'
import { createInertiaApp } from '@inertiajs/react'

async function resolvePageComponent<T>(
  path: string | string[],
  pages: Record<string, Promise<T> | (() => Promise<T>)>,
): Promise<T> {
  for (const p of Array.isArray(path) ? path : [path]) {
    const page = pages[p]

    if (typeof page === 'undefined') {
      continue
    }

    return typeof page === 'function' ? page() : page
  }

  throw new Error(`Page not found: ${path}`)
}

const appName = import.meta.env.VITE_APP_NAME || 'Rails'

createInertiaApp({
  title: (title) => `${title} - ${appName}`,
  resolve: (name) =>
    resolvePageComponent(
      `../Pages/${name}.tsx`,
      import.meta.glob('../Pages/**/*.tsx'),
    ),
  setup({ el, App, props }) {
    const root = createRoot(el)

    root.render(<App {...props} />)
  },
  progress: {
    color: '#4B5563',
  },
})

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kaze-0.8.0 stubs/inertia-react-ts/app/javascript/entrypoints/application.tsx
kaze-0.7.0 stubs/inertia-react-ts/app/javascript/entrypoints/application.tsx
kaze-0.6.0 stubs/inertia-react-ts/app/javascript/entrypoints/application.tsx