Skip to content

Instantly share code, notes, and snippets.

@chrfs
Last active December 26, 2018 18:36
Show Gist options
  • Save chrfs/78af2f34e2e21d975e7aab7c545e7990 to your computer and use it in GitHub Desktop.
Save chrfs/78af2f34e2e21d975e7aab7c545e7990 to your computer and use it in GitHub Desktop.
VueJS FontAwesomeIcon load all Icons
import Vue from 'vue'
import { library } from '@fortawesome/fontawesome-svg-core'
import * as faIconsSolid from '@fortawesome/free-solid-svg-icons'
import * as faIconsRegular from '@fortawesome/fontawesome-free-regular'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
const loadFontAwesomeIcons = (fontAwesomeIcons) => {
Object.keys(fontAwesomeIcons).forEach(faIconName => {
if (faIconName.startsWith('fa') && fontAwesomeIcons[faIconName].iconName) {
library.add(fontAwesomeIcons[faIconName])
}
})
}
loadFontAwesomeIcons(faIconsSolid)
loadFontAwesomeIcons(faIconsRegular)
Vue.component('font-awesome-icon', FontAwesomeIcon)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment