Use webpack to package js (synthetic js, imported in Html is very lightweight)

Hbulider X used

How to use webpack to compress related js files into one (not only compressed but also downgraded, from ES6 specification to ES5)

Changed files: models directory, index.html, webpack.config.js

1. models directory

A js that functions, a js that calls

 

2.webpack.config.js

Written entry entry: from which module's js entry

Written export output: Indicates where to stay after compression and downgrade, here according to the official

In fact, the final directory it generates looks like this:

It is dist->js->bundle.js

 

 3.index.html

This html file is used to <script> import the bundle.js just now, so that you can realize the content that multiple js should display without importing multiple js

 

 

 

Guess you like

Origin blog.csdn.net/SlinaW/article/details/127813281