fontawesome-module icon indicating copy to clipboard operation
fontawesome-module copied to clipboard

Not require listing all icons on nuxt.config.js

Open iBobik opened this issue 4 years ago • 1 comments

Hello, it is possible to not list all icons used on a whole site in nuxt.config.js, but benefit from tree shaking (load only icons used on the page)?

Ideally without strange technique using computed property.

iBobik avatar Jun 10 '21 18:06 iBobik

I think you can always use locally imported icons instead of gloable.

Use locally imported icons

<template>
    <div>
        <fa-layers full-width class="fa-4x">
          <fa :icon="fas.faCircle"/>
          <fa-layers-text transform="shrink-12" value="GALSD" class="fa-inverse" />
        </fa-layers>

        <fa :icon="fas.faAddressBook"  />
        <fa :icon="faGithub" />
    </div>
</template>

<script>
import { fas } from '@fortawesome/free-solid-svg-icons'
import { faGithub } from '@fortawesome/free-brands-svg-icons'

export default {
  computed: {
    fas () {
       return fas // NOT RECOMMENDED
    },
    faGithub () {
       return faGithub
    }
  },
}
</script>

Fabioni avatar Apr 13 '22 10:04 Fabioni