Webpack Getting Started

Source: Internet
Author: User

Webpack is a static resource manager running in node. js that generates various dependent files, such as js,.css,.png files. Installation is available through the NPM Package management tool.

First, install: Enter NPM install webpack-g on the command line to install Webpack in the Global environment, then webpack-h to view the installed Webpack,

Then you can use the Webpack command.

Second, use: After the installation of Webpack can be used, you can create a new folder under any folder, create a new index.html file

You can see the reference is the Bundle.js file, and now we do not have this file, then we will create this file, of course, we do not go directly to a new Bundle.js file. We create a new JS folder, create a new Index.js file, for example, we will use Webpack to package this JS file to generate the Bundle.js file we need, we must first use the command line to enter our file directory, and then use the command webpack Index.js Bundle.js, after which the command line shows that we executed the command successfully on our behalf,

, in the JS folder you will see the auto-generated bundle.js file, and then run index.html, you will find that the browser shows it works, which means that we have successfully generated the Bundle.js file.

Third, add the module: Of course Webpack function is not limited to this, but to a plurality of dependent modules packaging, now we are in the JS folder to create a new Module.js file, and add code, then we change our Index.js file, and then use the command line again Webpack Index.js Bundle.js Then refreshes the browser we found that the browser output, which indicates that our Module.js module was added successfully.

Webpack Getting Started

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.