Webpack Overview
webpack is a static module bundler for modern JavaScript applications.
Document: https://webpack.js.org/concepts/
Installation
|
|
webpack core concept
Entry
An entry point indicates which module webpack should use to begin building out its internal dependency graph. webpack will figure out which other modules and libraries that entry point depends on (directly and indirectly).
Output
The output property tells webpack where to emit the bundles it creates and how to name these files. It defaults to ./dist/main.js for the main output file and to the ./dist folder for any other generated file.
Loaders
Out of the box, webpack only understands JavaScript and JSON files. Loaders allow webpack to process other types of files and convert them into valid modules that can be consumed by your application and added to the dependency graph.
Plugin
While loaders are used to transform certain types of modules, plugins can be leveraged to perform a wider range of tasks like bundle optimization, asset management and injection of environment variables.
Mode
By setting the mode parameter to either development
, production
or none
, you can enable webpack’s built-in optimizations that correspond to each environment
Example
In webpack.config.js
|
|