Skip to content

Commit b1a35af

Browse files
committed
Update README
1 parent 1549bc2 commit b1a35af

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

UPGRADE.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,24 +143,20 @@ Inertia makes use of a `require()` call that is more complex to replicate with V
143143
The following function can be used instead:
144144

145145
```js
146-
function resolvePageComponent(name, pages) {
147-
for (const path in pages) {
148-
if (path.endsWith(`${name.replace('.', '/')}.vue`)) {
149-
return typeof pages[path] === 'function'
150-
? pages[path]()
151-
: pages[path]
152-
}
146+
export function resolvePageComponent(path, pages) {
147+
if (typeof pages[path] === undefined) {
148+
throw new Error(`Page not found: ${path}`)
153149
}
154150

155-
throw new Error(`Page not found: ${name}`)
151+
return pages[path]()
156152
}
157153
```
158154

159155
```diff
160156
createInertiaApp({
161157
title: (title) => `${title} - ${appName}`,
162158
- resolve: (name) => require(`./Pages/${name}.vue`),
163-
+ resolve: (name) => resolvePageComponent(name, import.meta.glob('./Pages/**/*.vue')),
159+
+ resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
164160
setup({ el, app, props, plugin }) {
165161
return createApp({ render: () => h(app, props) })
166162
.use(plugin)
@@ -284,9 +280,9 @@ If you were only using `postcss-import` to import Tailwind, then you may import
284280
- @import 'tailwindcss/base';
285281
- @import 'tailwindcss/components';
286282
- @import 'tailwindcss/utilities';
287-
+ @tailwind base
288-
+ @tailwind components
289-
+ @tailwind utilities
283+
+ @tailwind base;
284+
+ @tailwind components;
285+
+ @tailwind utilities;
290286
```
291287

292288
And then remove the plugin:

0 commit comments

Comments
 (0)