In my Vue 2.5 project (running with Laravel), I am interested in using FontAwesome fonts without relying on a CDN. The recommended approach for offline use is to include the following code in my app.js
:
import { library } from '@fortawesome/fontawesome-svg-core'
import { faUserSecret } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
library.add(faUserSecret)
Vue.component('font-awesome-icon', FontAwesomeIcon)
Within my Vue component (.vue
), I can then utilize the font like this:
<font-awesome-icon icon="user-secret" />
This process requires me to:
Select the
free
optionSearch for desired icons
Get the details of the chosen icon
Copy the corresponding code, such as:
<i class="far fa-eye"></i>
Modify my
app.js
(or an additional file likefontawesome.js
) and import the new icon:import { faUserSecret, faEye } from '@fortawesome/free-solid-svg-icons' library.add(faUserSecret) library.add(faEye)
Add
within my Vue component where needed<font-awesome-icon icon="eye" />
Do you believe this method is efficient and streamlined?