Sha256: aab60f4db4e9c94db5d3a3e3bc7c7538348c88fb39ebc932963231385d353bc6

Contents?: true

Size: 983 Bytes

Versions: 5

Compression:

Stored size: 983 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

5 entries across 5 versions & 1 rubygems

Version Path
kaze-0.5.0 stubs/inertia-react-ts/app/javascript/entrypoints/application.tsx
kaze-0.4.0 stubs/inertia-react-ts/app/javascript/entrypoints/application.tsx
kaze-0.3.0 stubs/inertia-react-ts/app/javascript/entrypoints/application.tsx
kaze-0.2.0 stubs/inertia-react-ts/app/javascript/entrypoints/application.tsx
kaze-0.1.0 stubs/inertia-react-ts/app/javascript/entrypoints/application.tsx