A
A
Andrey05022019-01-29 17:45:34
Vue.js
Andrey0502, 2019-01-29 17:45:34

Multiple Laravel/Vue frontend builds?

I am interested in building the front of a large project with many libraries, when app.js in prod already takes several megabytes. How relevant is it to break into separate assemblies and not pull everything in one app.js on each page?
I can not find good examples in the context of Laravel, I will be grateful for links to similar projects or a description of my own experience. Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2019-01-29
@Sanasol

something like this https://medium.com/js-dojo/3-code-splitting-patter...
But basically all the weight comes from dependencies that are still needed almost everywhere, and will be loaded anyway, only the same pieces. Although this is already better than one huge file.
In general, to begin with, find out exactly where the main piece of code lies.
Some css framework can be connected there, for example, and it stuffs all the css code in app.js to the heap.
So first of all, get rid of it, and then it will be visible.

A
Alex Wells, 2019-01-29
@Alex_Wells

Here's what you want: https://router.vuejs.org/guide/advanced/lazy-loadi...
Loads parts of the code as needed, and caches of course. True, I still don’t understand where you got a few MB of code in app.js.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question