How to import icon automatically when I use to reduce bundle size
masongzhi opened this issue · comments
MASONGZHI commented
when I want use to reduce bundle size, I must import icons manually like this
import 'vue-awesome/icons/file-audio';
import 'vue-awesome/icons/file-image';
import 'vue-awesome/icons/file-alt';
import 'vue-awesome/icons/file-video';
import 'vue-awesome/icons/film';
import Icon from 'vue-awesome/components/Icon';
Vue.component('icon', Icon);
Is there a way to import it automatically?
like use babel
to search automatically which icon I need to
GU Yiling commented
I'm afraid there is no existing tool for this. You need to implement it yourself. By using ESM, your dependency graph becomes statically analyzable. If you want to extract used icons from your code automatically, you need to ensure your usage is also analyzable. eg. only use .vue
files and templates with a fixed component name.