Install webpack:0. Webpack npm Install webpack-g in the global installation (if you do not have a webpack in the global, the local will not be recognized) 1. Enter the project installation directory via the command line, 2. Enter NPM init 3.npm webpack --save-dev
Webpack Packaging: Format webpack The file name after packaging the file name that you want to package for example: Webpack helloworld.js helloWorld.bundel.js
The successful operation will give us a part of the information: 1. Hash: Hashed 2.version:webpack version 3.Time: The time taken by this package is 4.Asset: This package generates a file of 5. Size This is a package of sizes 6. Chunks: This is a packed chunk
7.Chunk Names: Quick name for this package
When packaging, use--watch to monitor the transformation of the package file, so that the file changes package for example: Webpack helloworld.js helloWorld.bundel.js--watch
Loader reference: Some of the packaging process needs us to install some loader (such as CSS files, style) npm install Css-loader Style-loader--save-dev, also need require (' style-l oader!css-loader!. /style.css ') =
You can also add--module-bind ' Css=style-loader!css-loader ' when packing (recommended) For example: Webpack helloworld.js helloWorld.bundel.js--module-b IND ' Css=style-loader!css-loader '
Webpack parameters: 1:watch: Monitor 2.proggress: Packaging process 3.display-modules: View packaged modules 4.display-reasons: Why did you pack this module?
Webpack Basic Use (i)