I am currently experiencing an issue with compiling JS in a specific order. I need to compile the library or custom JS first, but the problem is that Laravel webmix compiles Vue components before the custom JS.
When I execute the command npm run dev
, all the JS files are merged into a single file at public/js/app.js
.
Unfortunately, the Vue components are added before the custom.js code. I want to prioritize compiling the custom.js code before the Vue component code.
app.js
require('./bootstrap');
require('./custom');
window.Vue = require('vue');
Vue.component('example-component', require('./components/ExampleComponent.vue').default);
Vue.component('product-list', require('./components/ProductListComponent.vue').default);
Vue.component('cart', require('./components/CartComponent.vue').default);
webpack.mix.js
const mix = require('laravel-mix');
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css');