0 votes
in GulpJS by
Webpack gives us a dependency graph. What does that mean?

1 Answer

0 votes
by

Any time one file depends on another, webpack treats this as a dependency. This allows webpack to take non-code assets, such as images or web fonts, and also provide them as dependencies for your application.

Webpack lets you use require() on local "static assets":

<img src={ require('../../assets/logo.png') } />  

When webpack processes your application, it starts from a list of modules defined on the command line or in its config file. Starting from these entry points, webpack recursively builds a dependency graph that includes every module your application needs, then packages all of those modules into a small number of bundles - often, just one - to be loaded by the browser.

The require('logo.png') source code never actually gets executed in the browser (nor in Node.js). Webpack builds a new Javascript file, replacing require() calls with valid Javascript code, such as URLs. The bundled file is what's executed by Node or the browser.

Related questions

0 votes
asked Jul 13, 2021 in GulpJS by SakshiSharma
+1 vote
asked Jan 30, 2020 in Azure by Tate
...