How to remove unused vector icons (from @expo/vector-icons)

Please provide the following:

  1. SDK Version: 48
  2. Platforms(Android/iOS/web/all): all
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

I’m using @expo/vector-icons only for the “createIconSetFromIcoMoon” function, so I’d like to remove the default fonts from my application builds.

With react-native-vector-icons, this can be done by specifying no font in the build.gradle file, and adding this in the react-native.config.js file:

module.exports = {
  dependencies: {
    'react-native-vector-icons': {
      platforms: {
        ios: null,
      },
    },
  },
};

How do you achieve the same behavior with @expo/vector-icons?

(I’ve also created an issue for this problem, but it seemed appropriate to create a post on the forum to reach more people, and allow more people to find the potential solution)

Hi @developer.isdecision

Does this do what you want?

import createIconSetFromIcoMoon from '@expo/vector-icons/createIconSetFromIcoMoon';

Hello again @wodin!
Indeed, this technique works. I wasn’t aware that these types of imports allowed for better tree-shaking than destructuring.

Thanks for the help!

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.