Webpack tutorial (1)-first experience, first experience
First, install webpack globally, then initialize a project in npm, and install the webpack development tool locally.
$ Npm install webpack-g
Npm init (project name)
$ Npm install webpack-dev-server -- save-dev
Create an app folder in the project directory, create an index. js file, and write the following code:
Console. log ('Hello World ');
Open the command line in the project folder and enter the following command
Webpack app/index. js build/index. js
The following code is successful:
Check the code of the build/index. js file:
The 73 lines are the code of our app/index. js file.
We will analyze the specific source code in another day. Today, our main goal is to experience it.
In this way, coding is too inefficient. We can use the webpack. config. js file to complete more advanced functions.