官术网_书友最值得收藏!

  • JavaScript by Example
  • Dani Akash S
  • 259字
  • 2021-07-02 18:39:10

Webpack module bundler

It's finally time to set up our fully-featured development environment. You'll probably be wondering what Webpack is and what's it got to do with a development environment. Or perhaps, you are familiar with tools such as gulp or grunt and are wondering how Webpack is different from them.

If you have used gulp or grunt before, they are task runners. They execute a specific set of tasks to compile, transform, and minify your code. There is also a tool called Browserify, which lets you use require() in browsers. Usually, a development environment with gulp/grunt involves executing various commands using different sets of tools, such as Babel, Browserify, and so on, in a specific order to generate our desired output code. But Webpack is different. Unlike task runners, Webpack doesn't run a set of commands to build the code. Instead, it acts as a module bundler.

Webpack goes through your JavaScript code and looks for import, require, and so on to find files dependent on it. Then, it loads the files into a dependency graph and, in turn, finds those files, dependencies. This process goes on until there are no more dependencies. Finally, it bundles the dependency files together with the initial file into a single file using the dependency graph it built. This functionality is very useful in modern JavaScript development, where everything is written as a module:

Webpack is being adopted as the bundler of popular modern frameworks, such as React, Angular, and Vue. It is also a good skill to have on your resume.
主站蜘蛛池模板: 二手房| 衡南县| 景宁| 河西区| 高邑县| 长顺县| 利辛县| 邮箱| 饶平县| 滕州市| 龙州县| 右玉县| 开原市| 淮南市| 同心县| 栾城县| 文安县| 个旧市| 革吉县| 忻州市| 嘉禾县| 泰宁县| 咸阳市| 星子县| 紫阳县| 五大连池市| 沂南县| 堆龙德庆县| 丹阳市| 内乡县| 日土县| 库车县| 蒙阴县| 修水县| 肇源县| 长葛市| 渝中区| 绥宁县| 黄浦区| 鱼台县| 南城县|