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.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,940評(píng)論 0 23
  • 文/吾愛廬 前一段時(shí)間的下午,同事將我交給他的工作任務(wù)單,當(dāng)著我的面甩在地上,說這不是我的活,我當(dāng)沒收到。...
    吾愛廬閱讀 673評(píng)論 4 4
  • 希望我有很多很多的時(shí)間,讓我做很多很多我喜歡做的事。隨心起意,是我。
    熬夜看愛四閱讀 260評(píng)論 0 0
  • 尊敬的曉荷媽媽好! 尊敬的己革老師好! 尊敬的陳喜老師好! 2017.8.20 青島孫碩媽...
    孫碩媽閱讀 118評(píng)論 0 0
  • 惱火是南方話,資訊發(fā)達(dá)的今天估計(jì)全國(guó)人民都明白這是不爽、煩著呢的意思。今天我就挺惱火,怒火往外直冒,既惱火又委屈,...
    元?dú)饬捍蠼?/span>閱讀 529評(píng)論 0 1