javascriptvuetify.jses6-modules

Import multiple entries from a module and assign to some alias


I want to import several entries from a module and assign to some alias. Is that possible? Currently I do

import {
  mdiAlert,
  mdiCheck,
  mdiDelete,
  ... 40 more ...
} from '@mdi/js'

export default new Vuetify({
  icons: {
    values: {
      mdiAlert,
      mdiCheck,
      mdiDelete,
      ... 40 more ...
    }
  }
})

Is is possible to import { one, two, three } as something from 'module' somehow to avoid code duplication?


Solution

  • I accidentally found a way 4 years later. You just create icons.ts file with export {..} from syntax:

    export {
      mdiAlert,
      ...40 more...
    } from '@mdi/js'
    

    And then just import it with import * as syntax:

    import * as mdiIcons from './icons'
    
    export default new Vuetify({
      icons: {
        values: mdiIcons
      }
    }