Webpack Front-End build Tool Learning Summary (iii) of the Webpack.config.js configuration file

Source: Internet
Author: User

Webpack can also be executed with the specified configuration file, in addition to passing parameters at the command line. By default, the file for the current directory webpack.config.js is searched, which is a node. JS module that returns a JSON-formatted configuration information object, or a --config configuration file with the option to specify it.

Webpack Document: https://webpack.github.io/docs/

1. Create a new folder SRC store the pre-packaged source files, Dist folder to store the packaged files, create a new webpack.config.js webpack configuration file

Contents of the folder before packaging

2. Create a new index1.html reference dist under the packaging of JS

3. Input command: Webpack, can be compiled according to the configuration item in Webpack.config.js

4. Compile the file directory and content as follows

5. If Webpack.config.js is renamed to Webpack.dev.config.js, the default Webpack command will not be found and the configuration file needs to be specified with the--config option of Webpack

Command: Webpack--config webpack.dev.config.js

6. If you want to see the progress of the compilation, such as packaged modules, you can specify the value of the Webpack property within the scripts tag in Package.json

7. Input command: NPM run Webpack, to compile the package

Detailed description of the entry value in Webpack.config.js:

Https://webpack.github.io/docs/configuration.html#entry

The value of the entry can be a string of type or an array, or it can be a JSON object

Array: This will package the contents of the file in the array defined by entry into this file defined in the output

JSON object: This situation is suitable for multi-page compilation

Description of the Output property value: Https://webpack.github.io/docs/configuration.html#output

Using the command: NPM run Webpack, compiling the package will see that two files are generated under DIST/JS

Webpack Front-End build Tool Learning Summary (iii) of the Webpack.config.js configuration file

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.