First attempt at webpck

Recently a project needs to use typeScript.

Would like to take this opportunity to review and review, step up, npm, and the use of webpack.


above sea level

npm init -y generates a simple package.json file

npm install install dependencies.

npm install [email protected] depends on the package to install the specified version




webpack

Overview:

The basic principle is to bundle a series of js files into one js. By the way, solve the dependency problem of js.

Webpack does not operate on js. If you use ecma2015 js, you need loader to convert js.

Basic operation:

run: webpack


Basic installation:
mkdir webpack-demo && cd webpack-demo
npm init -y generate a simple package.json file

webpack scaffolding
npm install webpack webpack-cli --save-dev

browser auto refresh.
webpack-dev-server

introduces lodash: main For array processing.
npm install --save lodash

 path.resolve(__dirname, 'dist')
 Inside any module file, you can use the __dirname variable to get the full absolute path to the directory where the current module file is located.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325832322&siteId=291194637