Webpack is a modular bundler that applies to the largest single-page web application and can be bound to a single task operator tie it together, it can handle java, css, etc. Webpack is a good complement to the front-end developers' tool set, using webpack, and web develops faster, more efficient and more interesting。
What's a modular bundler
In most programming languages, we can divide the code into multiple files and import them into the application to use the functionality contained therein. This is not embedded in the browser, so the builder of the module binder will provide this feature in many forms: by loading the modules on foot and running them after loading has been completed; or by loading the label through HTML by combining all necessary files into a java file。
Without modular loaders and bundlers, we can also manually group files or load HTML into numerous labels at any time, but this has several disadvantages:
1. We need to track the correct order in which documents should be loaded, including which other documents depend and ensure that no documents are required。
2. Multiple labels mean multiple calls to the server to load all codes, which is worse for performance。
Three, it takes a lot of manual work, not computers to do it for you。
Why webpack
Select webpack for the following reasons:
It is relatively new, as it can address or avoid the shortcomings and problems of its predecessors。
The introduction is simple. If we just want to tie a bunch of java files together without anything else fancy, we don't even need configuration files。
3. Its plugin system enables it to do more and makes it very powerful. So it may be the only building tool we need。
Webpack implementation
Webpack started from the entry (entry), usually the java modules, where webpack started its journey. In doing so, webpack evaluates the entry (entry) according to the loader configuration, which tells us how webpack will convert each match。
Parsing process
The entry is itself a module. When webpack encounters an entry, webpack tries to match the entry to the file system using a list configuration. In addition to the node modules, we can also tell webpack to do a search for a specific directory. You can also adjust the way webpack matches the file extension and you can define specific aliases for the directory. These ideas are covered in greater detail by the depletion and charter。
If the resolution fails, webpack triggers run-time errors. If webpack tries to parse the file correctly, webpack will execute the processing of matching files according to the loader definition. Each loader applies a specific conversion to the contents of the module。
The loader can be configured in a number of ways to match the parsed file, including the file type and location of the file system. Webpack's flexibility even allows us to apply specific conversions to files according to where they are imported。
The same process is performed for webpack loaders. Webpack allows us to apply a similar logic in determining which loader to use. For this reason, the loading program has already parsed its configuration. If webpack is unable to execute the loading program search, run-time error occurs。




