Webpack Command Execution parameters and webpack Parameters
I. Overview
The previous sections explain how to install and use webpack. config. the basic configuration of js, the name of webpack execution, and the use of the require method are unknown. Every time we modify or add a js file, it will re-execute the webpack command for compilation, which is very troublesome, so that the whole project will not be executed millions of times. Next we will explain the webpack-related parameters to avoid this situation.
Ii. Parameter Details
You can add some parameters after running the webpack command. These parameters have their own functions. The following lists the parameters:
$ Webpack -- config XXX. js // use another configuration file (such as webpack. config2.js) to package $ webpack -- watch // listen for changes and automatically package $ webpack-p // compressed obfuscation scripts. This is very important! $ Webpack-d // generate a map ing file to tell which modules are finally packaged to where $ webpack -- progress // display progress bar $ webpack -- color // Add color
-P is a very important parameter. Once an uncompressed kb file was compressed and directly reduced to kb after compression (mainly because the style field occupies a script exclusively, causes uncompressed scripts to become very large ).
Here, we will focus on the webpack-watch parameter. The function of this parameter is to check whether the listening file has changed. If it has changed, the file will be re-compiled. This command is very useful. Next we will use a webpackDemo project as a demonstration.
First, run the webpack -- watch command on the terminal:
You can see that after the command is executed, webpack will continue to run, instead of stopping after the webpack command is executed. Next, let's modify the login. js content to see what changes will happen to the terminal:
var userName="68kejian.com";module.exports.userName=userName;module.exports.sayName=function(){ return userName;};module.exprots.login=function(){};
The login () method is added, and the terminal changes at this time:
Compared with the previous one, there are more records compiled for the login. js file.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.