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