SVG icon component - should be included in any view/component?

I’ve created an SVG icon component(followed this nice article) and I wonder if I should somehow modify my config file to include this component in every Vue component, as it’s going to be used in many components, so I will no have to import and declare it over and over again.
What do you think?
Do you have such a common basic component which is included in every view or component? How did you do it?(webpack rule?)

You could register the component globally. e.g. in the same file where you create your root Vue component:

import App from './App.vue'
import router from './routes.js'
import SvgIcon from './SvgIcon.vue'

// allow any component to use <svg-icon ... /> without declaring it...
Vue.component('svg-icon', SvgIcon);

new Vue({
  router,
  ...App
});
1 Like