Answer the question
In order to leave comments, you need to log in
How to set up Laravel Mix to build asynchronous Vue.js components?
I use asynchronous component loading . Everything works, but not exactly as we would like. Laravel Mix .js
does not build component files into public > js
, but simply into public
. Secondly, it would be nice to name the files with the name of the component. Although the second is not so important, the main thing is to deal with the first problem.
app.js
import Vue from 'vue'
import router from "./router";
import App from './components/App.vue'
new Vue({
el: '#app',
router,
render: h => h(App)
})
import Vue from "vue";
import Router from "vue-router";
Vue.use(Router);
export default new Router({
mode: 'history',
routes: [
{
path: "/",
component: () => import("./components/ProductList.vue")
},
{
path: "/cart",
component: () => import("./components/ShoppingList.vue")
}
]
});
const mix = require('laravel-mix');
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question