How to dynamically load a Vue component after using require.context? How to dynamically load a Vue component after using require.context? vue.js vue.js

How to dynamically load a Vue component after using require.context?


const requireContext = require.context('./components', false, /.*\.vue$/)const dynamicComponents = requireContext.keys()    .map(file =>        [file.replace(/(^.\/)|(\.vue$)/g, ''), requireContext(file)]    )    .reduce((components, [name, component]) => {        components[name] = component.default || component        return components    }, {})