Webpack
Webpack is a packaging tool, the scientific name is called the Module Packager, all the modules packaged into one or a small number of files, so that you just load a small number of files to run the entire application, without the need to load a lot of pictures, CSS files, JS files, font files and so on as before.
Compared to Gulp/grunt's automated build tool, Webpack is relatively weak in js,css compression, code checking, and compilation. Because plug-ins are not broad enough. So someone will combine the two together, a better way is to use NPM script instead of gulp to complete the task.
A complete configuration is like this. A little bit more, but it doesn't matter. Part of it is actually totally useless.
Package JS
Need to develop entry and output, in the JS file using import syntax to write module dependencies. You can load all the dependencies smoothly.
Module.exports = { './src/index.js', output: { ' ./dist'), 'bundle.js' }}
Loader and plugin, what's the difference?
Loader (loader), heavy in the "load" word, is used to preprocess files, only for loading different types of files when the different types of files to do the corresponding processing. and plugin (plug-in), as the name implies, is used to increase the function of Webpack, acting on the entire webpack construction process. In Webpack this large company, loader is the security uncle, responsible for the different personnel to enter the company's handling, and plugin is the company's different positions of staff, responsible for the company's various business, each to add a new business needs, we need to add a plugin.
Module Hot swap (HMR)
Update only the modules that have changed (replace, add, delete) without reloading the entire page (live load,livereload), which can significantly speed up development, once the hot mode of Webpack-dev-server is turned on, Hot mode attempts to update using HMR before attempting to reload the entire page.
Webpack3+react Building Apps