25.06.2018 Views

Full-Stack Vue.js 2 and Laravel 5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Bundling<br />

The process of resolving modules into browser-friendly code is called bundling.<br />

Webpack begins the bundling process with the entry file as a starting point. In<br />

the <strong>Laravel</strong> frontend app, resources/assets/<strong>js</strong>/app.<strong>js</strong> is the entry file.<br />

Webpack analyzes the entry file to find any dependencies. In the case of app.<strong>js</strong>, it<br />

will find three: bootstrap, vue, <strong>and</strong> Example.vue.<br />

resources/assets/<strong>js</strong>/app.<strong>js</strong>: require('./bootstrap'); window.<strong>Vue</strong> = require('vue');<br />

<strong>Vue</strong>.component('example', require('./components/Example.vue')); ...<br />

Webpack will resolve these dependencies <strong>and</strong> then analyze them to find any<br />

dependencies that they might have. This process continues until all dependencies<br />

of the project are found. The result is a graph of dependencies that, in a large<br />

project, might include hundreds of different modules.<br />

Webpack uses this graph of dependencies as a blueprint for bundling all the code<br />

into a single browser-friendly file:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!