After a new Laravel 9 installation with Inertia, Tailwind, Breeze using Vue 3 I decided to get FontAwesome installed. I'm not using the Type Kit but a manual installation with npm.
Following all of the instructions and guides I can find. (https://fontawesome.com/docs/web/use-with/vue/) I cannot get this to work.
I've tried Googling "Inertia.js FontAwesome", "Vue3 Inertia Global Components" and others - there's what I think should work and it looks something like what I'm seeing in my googling. But when I try, I get nothing.
Here we go:
import { createApp, h } from 'vue';
import { createInertiaApp } from '@inertiajs/inertia-vue3';
/* From the FontAwesome Docs */
import { library } from '@fortawesome/fontawesome-svg-core'
import { faSun, faMoon } from '@fortawesome/pro-duotone-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
library.add(faSun, faMoon)
const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';
createInertiaApp({
title : (title) => `${title} - ${appName}`,
resolve: name => import(`./Pages/${name}`),
setup({el, app, props, plugin}) {
return createApp({render: () => h(app, props)})
.use(plugin)
/* Here's where I try what I *think* will work */
.component('FontAwesomeIcon', FontAwesomeIcon)
.mixin({methods: {route}})
.mount(el);
},
});
Then in a Layout or Page or other Component (I've tried them all):
<FontAwesomeIcon icon="fa-duotone fa-sun" />
Then in the console, I get this error:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'icon')
I thought I was getting used to Vue3, it's my first time with Inertia. But now I feel like there's something basic I've missed in all I've read. Like I missed the memo with either Inertia or Vue with how things are supposed to work now. Getting FontAwesome to work in Laravel 8 with Vue 2 was a cinch. Why am I struggling so much with this? Can someone please point out the obvious thing I've done wrong?