Webpack Command Execution parameters and webpack Parameters

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.