Created
August 27, 2019 14:27
-
-
Save ManUtopiK/f0572f3a9bccea43a4de4ab620347304 to your computer and use it in GitHub Desktop.
Import multiple svg in nuxt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Vue from 'vue' | |
| import forEach from 'lodash/forEach' | |
| const icons = require.context('~/icons', false, /[A-Z]\w+\.(svg)$/) | |
| forEach(icons.keys(), (fileName) => { | |
| const iconConfig = icons(fileName) | |
| const iconName = fileName.split('/').pop().split('.')[0] | |
| Vue.component(iconName, iconConfig.default || iconConfig) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment