Vue.js lazy loading

Published 3 weeks ago by Lars-Janssen

I'm using Laravel mix for compiling my vue.js components. Now I would like to lazy load my components found it here:

https://vuejs.org/v2/guide/components.html#Async-Components

When I try this:

Vue.component('setting', () => import('./components/settings/setting.vue'));

I get:

 error  in ./resources/assets/admin/vue/core.js

Syntax Error: Unexpected token (36:31)

  34 |  */
  35 |
> 36 | Vue.component('setting', () => import('./components/settings/setting.vue'));
     |                                ^

What could be wrong here? When I register the component 'normal' everything is working?

robrogers3

does babel know about dynamic imports?

https://babeljs.io/docs/plugins/syntax-dynamic-import/

.babelrc

{
  "plugins": ["syntax-dynamic-import"]
}

Please sign in or create an account to participate in this conversation.