vaso2 / nuxt-fontawesome

Nuxt module for Fontawesome 5 integration with ES6 imports and tree shaking
MIT License
107 stars 4 forks source link

refactor: cleanup plugin, use single import for each set #13

Open pimlie opened 5 years ago

pimlie commented 5 years ago

feat: make layer components configurable chore: update dependencies test: add test for tree shaking

Thanks for this nuxt module, I use it very often! Have made some refactors to improve the overall usage. Let me know if you have any remarks.

Please also check the new addLayers and addLayersText options as I was not sure how I should name these. Feel free to suggest a better name

After this pr the plugin will look like this:

import Vue from 'vue'
import { library, config } from '@fortawesome/fontawesome-svg-core'
import {
  FontAwesomeLayers,
  FontAwesomeLayersText,
  FontAwesomeIcon
} from '@fortawesome/vue-fontawesome'

import {
  faCog as fortawesomefreesolidsvgicons_faCog,
  faCalendar as fortawesomefreesolidsvgicons_faCalendar,
  faHome as fortawesomefreesolidsvgicons_faHome,
  faCircle as fortawesomefreesolidsvgicons_faCircle,
  faCheck as fortawesomefreesolidsvgicons_faCheck
} from '@fortawesome/free-solid-svg-icons'

library.add(fortawesomefreesolidsvgicons_faCog)
library.add(fortawesomefreesolidsvgicons_faCalendar)
library.add(fortawesomefreesolidsvgicons_faHome)
library.add(fortawesomefreesolidsvgicons_faCircle)
library.add(fortawesomefreesolidsvgicons_faCheck)

config.autoAddCss = false

Vue.component('fa', FontAwesomeIcon)
Vue.component('fa-layers', FontAwesomeLayers)
Vue.component('fa-layers-text', FontAwesomeLayersText)