29 lines
875 B
TypeScript
29 lines
875 B
TypeScript
import { createInertiaApp } from "@inertiajs/react";
|
|
import { resolvePageComponent } from "laravel-vite-plugin/inertia-helpers";
|
|
import { createRoot } from "react-dom/client";
|
|
import axios from "axios";
|
|
|
|
// @ts-expect-error Env is always present.
|
|
const appName = import.meta.env.VITE_APP_NAME || "Laravel";
|
|
|
|
createInertiaApp({
|
|
title: (title) => `${title} - ${appName}`,
|
|
resolve: (name) =>
|
|
resolvePageComponent(
|
|
`./${name}.tsx`,
|
|
// @ts-expect-error Glob error.
|
|
import.meta.glob("./*/Pages/**/*.tsx"),
|
|
),
|
|
setup({ el, App, props }) {
|
|
const root = createRoot(el);
|
|
|
|
// eslint-disable-next-line react/jsx-filename-extension, react/jsx-props-no-spreading
|
|
root.render(<App {...props} />);
|
|
},
|
|
progress: {
|
|
color: "#4B5563",
|
|
},
|
|
});
|
|
|
|
window.axios = axios;
|
|
window.axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";
|