A
A
Artem00712018-12-27 14:22:02
Laravel
Artem0071, 2018-12-27 14:22:02

Is it possible to include lazyloading in a Laravel project?

If you use vue-cli as a separate application, then the following construction is available out of the box:

component: () => import('./app/layouts/MainLayoutComponent'),

Thus, the component will be loaded only on request.
I transferred the same code to the Laravel project, where vue is already preinstalled, but when you start it, npm run watchwhy do you give an error:
Add @babel/plugin-syntax-dynamic-import (https://git.io/vb4Sv) to the 'plugins' section of your Babel config to enable parsing.

But I can't find it anywhere , it 's Babel config...only webpack.mix.jsin the root of the project . added a file to the root of the project and wrote in it:
npm install @babel/plugin-syntax-dynamic-import
.babelrc
{
  "plugins": ["@babel/plugin-syntax-dynamic-import"]
}

The error is gone, but lazy load doesn't work.. Still loading with one file

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question