webpack in the region loader and plugin

How webpack the plugin loader and distinguish these two concepts.

For the loader, it is a converter, the compiled file A file B is formed, where the file operation, such as the A.scss or A.less into b.css, simple file conversion process;

For plugin, it is an extender, it enriches wepack itself, for after the end of the loader, webpack packaged the whole process, it does not directly manipulate files, but event-based mechanism to work, listens webpack some of the packaging process node, for example,

run: start compiling
make: from the entry start the recursive analysis be dependent and rely build
build-moodule: Use loader to load the file and build the module
normal-module-loader: file loader loaded with acorn compiler generates abstract syntax tree AST
Program: AST began to traverse, call require a trigger event when it comes to the require
Seal: all depend build complete, began chunk optimization (extraction public module, plus hash, etc.)
optimize-chunk-Assets: compressed code
emit: the output of each chunk to the outcome document
by listening to the nodes, the nodes in order to find the right file to make the appropriate treatment.

 


Original link: https: //blog.csdn.net/yq_oxygen/java/article/details/78107696

Guess you like

Origin www.cnblogs.com/whdaichengxu/p/12660378.html