I: definitions
Webpack can see it as a modular charter: what it does is analyze your project structure and find javasOutreach languages that cannot be directly run by cript modules and some other browsers (scs, types)Cript, etc.) and convert and package them into appropriate formats for browsers。
It's white: the language at the back end, the browser can't solve it, and the webpack is the middleman, packing the data, translating it to the language that the browser can recognize, and finally rendering the page.
Ii: use of webpack
Installation:
Installation within the project;
, first execute the npm command and install the json file npm init-y = > will install json files install package npm i (install) webpack-save-dev ps: webpack will only be installed at the project where the json file is located if the json file is installed first
View code
Global installation
Install webpack globally no, no, no, no. You can use webpack in any directory webpack entrance file, exit file
View code
Iii: use of codes:
All the files in node's eyes are modules, two mouths, one entrance, one out. Mouth
Example:
Step 1:
"s"Cripts: "test": "echo": no test designed" & "exit 1", "pack": "node modules/. Bin/webpack" #configured path ♪ i don't know ♪ since we're installed in the project, all of the wenpacks are installed in the bin directory, so first you configure the path. Later call direct running command: npm run pack
Configure webpack path in packjage to reduce code generation
Second:
I'm sorry. Entry: here'./next/home. Js', #input port, formerly file name, then file path signup:'./text/signup. Js♪ i'm sorry ♪ }, / / file to output first name i'm sorry. Filename:'[name]. Book. Js', #[name] refers to the host and signup entry above, the official order refers to the stored export first name path: dirname+'/dist', / /export save file path ♪ i'm sorry ♪ ♪ i'm sorry ♪
Configure webpack. Config. Js files, remember how file steps change
Third, write down the logical code at the entrance and achieve the final entry code
BCase. Js files
Var open = true;
(a) export{open};
Information for judgement
Home. Js files
I{open} from'./bI'm sorry♪ i'm sorry ♪
if (open)
d== sync, corrected by elderman ==Registration`
♪ i'm sorry ♪
IntroductionbSase. Js file bool value, act accordingly
Signup. Js files
I{open} from'./bI'm sorry♪ i'm sorry ♪
if (open)
aLett();
♪ i'm sorry ♪
ReferencebAn example, make a choice
Step 4: production of export documents
Var open = true; ps: file name is created by configuration of webpack. Config. Js
I'm sorry, home
Var open = true; if( webpack i)Mported module 0 b["a" ] d== sync, corrected by elderman ==Registration` ♪ i'm sorry ♪
I'm sorry, signup
Finally, the creation of the file can be quoted in other HTML
"./dist/home. Book. Js"I'm sorry"./dist/signup. Bundle. Js"I'm sorry. Different results
Aa. HTML
The table of contents is as follows:




