-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make an icon component specifically for tree shaking #475
Comments
@jpengelbrecht ---
Do you have a repo where you have done this, a PR, or some code perhaps that I could see/review on this ? |
I don't have a repo for this no. but using this method, https://fontawesome.com/docs/apis/javascript/tree-shaking |
@jpengelbrecht --- I think I get what you are saying then... So currently to use the Font Awesome icons in vue we do have to import This allows us to use icons in our vue components: But we also need to import icons or at least 1 icon (via tree shaking): So how do we still use Font Awesome icons without importing the I think that is what you are questioning/asking? |
@jasonlundien exactly. you can still use |
I've measured the size of my bundle. Without any font-awesome:
Merely registering the component like thisimport { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
Vue.component('font-awesome-icon', FontAwesomeIcon) Increases the bundle size:
Adding the
|
Hello @WhyNotHugo we have some docs on using the plugin system to pick-n-choose features: https://fontawesome.com/docs/apis/javascript/plugins This helps to reduce size but it may not get the bundle size down as small as you would like. It's worth a look though! |
My main issue is that each script ends up bundling the same component, so each output script jumps in size by 60kB just by using a single icon. I've managed to somewhat improve the situation by making sure that Vite puts the icon component into its own file, and different pages will just load the same one (this will often be a cache hit, so it'll only be loaded once). I just added this into output: {
manualChunks: {"fa": ["@fortawesome/vue-fontawesome"]},
} Bundle sizes:
|
Thanks, @robmadole, but that seems to only reduce the size of the core svg bundle. What's really bumping my modules size is this specific bit:
In order to reduce the size of that one, I think I'd need my own build of the Vue component, which depends on my own build of svg-core as described in https://fontawesome.com/docs/apis/javascript/plugins. |
fontawesome-svg-core/index.mjs comes in at a whooping 60.187 KiB . so if i am using the treeshaking method by importing the icons i need and using the "@fortawesome/vue-fontawesome" component the display component makes up about 3% of my entire bundle size. i would imagine if you make a sleeker version that is only made for explicitly passing through the imported icon as a prop we can do away with a lot of the logic bulking up this component
The text was updated successfully, but these errors were encountered: