webpack installation, entry file

1, and installation WebPACK webpack-cli

// create webpack folder and enter the folder 
cd webpack 
npm the init 
npm install webpack webpack the -cli --save-de

Node_modules automatically generated files and file package.json after installation, the package file package.json labeled version of WebPACK and webpack-cli

 

2, single-file package, create the index.html file, and the introduction of built js file webpack

3. Create the src folder and create index01.js file in the src folder, which is the need to package documents

4, create webpack.config.js file, which is webpack configuration file, packaged index01.js file to generate a new file

5, Run webpack build project will generate dist (resettable storage path build) the folder, the folder with a packaged js file, use is introduced as index.html.

npx webpack --config webpack.config.js

6, after setting the new package file storage path

7, modify the operating mode
of the original mode

npx webpack --config webpack.config.js

Now the way, in package.json the script to set a new operating mode,

Its new operating mode for the

cnpm run dev


8, packing multiple files simultaneously packaged two js files and use these files in html

9, create index02A.js and index02B.js files in the src folder,

10, the configuration file is packaged in a multi-webpack.config.js configuration file, name of the corresponding object entry entry keys.

Guess you like

Origin www.cnblogs.com/Ladai/p/11768292.html