Created
December 23, 2019 14:27
-
-
Save hawkeye64/1b65070b5d75c998b2a8b3caa3d3cb73 to your computer and use it in GitHub Desktop.
Dynamically load Vue components from a folder
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
export default ({ Vue }) => { | |
const examples = require('../assets/examples').default | |
for (const index in examples) { | |
import( | |
/* webpackChunkName: "examples" */ | |
/* webpackMode: "lazy-once" */ | |
`../examples/${examples[index].file}.vue` | |
).then(comp => { | |
Vue.component(examples[index].file, comp.default) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
assets/examples.js goes like this: