I'm currently working on a Laravel 8 project with vue.js v2.6 and I want to clean up my app.js file by moving all of my Vue.component() declarations to a separate file. To achieve this, I created js/vueComponents.js where I placed all the vue component declarations. However, when trying to import and use require() in app.js, I encountered some errors:
app.js:4301 Uncaught TypeError: $ is not a function
at Module../node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components...
As I am new to importing JavaScript files as modules, I'm wondering if I'm doing this correctly?
vueComponents.js
import * as Vue from 'vue'
export let vueFiles = [
Vue.component('users-page', require('./components/users-page.vue').default),
Vue.component('admin-page', require('./components/admin-page.vue').default),
...20 more components...
];
app.js
import { vueFiles } from './vueComponents.js';
Vue.use(vueFiles);