webpack模块

In modular programming, developers break programs up into discrete chunks of functionality called a module.

Each module has a smaller surface area than a full program, making verification, debugging, and testing trivial.
Well-written modules provide solid abstractions and encapsulation boundaries, so that each module has a coherent design and a clear purpose within the overall application.

Node.js has supported modular programming almost since its inception.
On the web, however, support for modules has been slow to arrive.
Multiple tools exist that support modular JavaScript on the web, with a variety of benefits and limitations.
webpack builds on lessons learned from these systems and applies the concept of modules to any file in your project.

What is a webpack Module

In contrast to Node.js modules, webpack modules can express their dependencies in a variety of ways. A few examples are:

  • An ES2015 import statement
  • A CommonJS require() statement
  • An AMD define and require statement
  • An @import statement inside of a css/sass/less file.
  • An image url in a stylesheet (url(...)) or html (<img src=...>) file.

T> webpack 1 requires a specific loader to convert ES2015 import, however this is possible out of the box via webpack 2

Supported Module Types

webpack supports modules written in a variety of languages and preprocessors, via loaders. Loaders describe to webpack how to process non-JavaScript modules and include these dependencies into your bundles.
The webpack community has built loaders for a wide variety of popular languages and language processors, including:

And many others! Overall, webpack provides a powerful and rich API for customization that allows one to use webpack for any stack, while staying non-opinionated about your development, testing, and production workflows.

For a full list, see the list of loaders or write your own.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,934评论 0 23
  • 文/吾爱庐 前一段时间的下午,同事将我交给他的工作任务单,当着我的面甩在地上,说这不是我的活,我当没收到。...
    吾爱庐阅读 673评论 4 4
  • 希望我有很多很多的时间,让我做很多很多我喜欢做的事。随心起意,是我。
    熬夜看爱四阅读 260评论 0 0
  • 尊敬的晓荷妈妈好! 尊敬的己革老师好! 尊敬的陈喜老师好! 2017.8.20 青岛孙硕妈...
    孙硕妈阅读 118评论 0 0
  • 恼火是南方话,资讯发达的今天估计全国人民都明白这是不爽、烦着呢的意思。今天我就挺恼火,怒火往外直冒,既恼火又委屈,...
    元气梁大姐阅读 523评论 0 1