Skip to content

Instantly share code, notes, and snippets.

@yaman3bd
Last active April 18, 2021 12:10
Show Gist options
  • Save yaman3bd/0567a41d03eea5044a293d2ae9e95eaa to your computer and use it in GitHub Desktop.
Save yaman3bd/0567a41d03eea5044a293d2ae9e95eaa to your computer and use it in GitHub Desktop.
Auto register Vue3 components
//in your app.js add this:
window.Vue = require('vue');
const app = Vue.createApp({});
const files = require.context('./', true, /\.vue$/i);
files.keys().map(function (key) {
app.component(key.split('/').pop().split('.')[0], files(key).default);
});
app.mount('#app');
//in your HTML should be like:
<body class="come-class">
<div id="app" class="come-class">
<my-component></my-component>
</div>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment