GregYankovoy / vue-cli-plugin-fontawesome

MIT License
7 stars 0 forks source link

Vue 3 with Typescript #9

Open wattsie opened 3 years ago

wattsie commented 3 years ago

Hi, Nice plugin.

With latest vue-cli using Vue 3 and Typescript, this plugin no longer works as expected. ie, you can nolonger use import Vue from 'vue'

However, by change the following, one can get it working...

package.json:

  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.34",
    "@fortawesome/free-solid-svg-icons": "^5.15.2",
    "@fortawesome/vue-fontawesome": "^3.0.0-3",
    .....

plugins/fontawesome.ts

import { library } from '@fortawesome/fontawesome-svg-core'
import { fas } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
library.add(fas)
export { FontAwesomeIcon }

main.ts // assuming the createApp(App) is broken up and not chained

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './assets/tailwind.css'

import { FontAwesomeIcon } from "@/plugins/fontawesome"

const app = createApp(App)
app.use(store)
app.use(router)
app.component('font-awesome-icon', FontAwesomeIcon)
app.mount('#app')

Many thanks for your excellent plugin.

fershopls commented 3 years ago

Thank you so muuuch! This should be on the documentation, just had the same issue.

However it worked for me importing the component on each .vue file instead using

app.component() function

GregYankovoy commented 3 years ago

Hi! Thanks for the information. I will look into incorporating this into the plugin as an option.