1. Installation
Global Installation:
NPM Install Webpack-g
Install in the project directory:
NPM Install Webpack--save-dev
Package File Base command:
Webpack Source.js Bundle.js
2. Configuration
Create a webpack.config.js profile in the directory, or you can specify the configuration file with --config ; In a configuration file, specify a configuration file with Module.exports, and each configuration parameter is in the form of a key-value pair:
(1) Portal Configuration Entry: string/Array/object
String: Single entry file
Array: A single entry, but there are multiple interdependent files
Object: Multiple entry file, at this time the corresponding export filename will be changed to multi-exit form, or will be error
(2) Export configuration output: Object form. where the path and filename fields represent a packaged path and a packaged file name, note that when there are multiple portals, the packaged file name is modified to be automatically generated.
(3) Example:
Const PATH = require (' path '); module.exports = { entry: { main: './src/script/main.js ', A: './src/script/ A.js ' }, output: { path:path.resolve (__dirname, ' Dist/js '), filename: ' [name].js ' }}
Webpack First Knowledge