Use webpack --- installation webpack and webpack-dev-server

1. Make sure you have the latest version of Node.js and NPM, and the NPM already know the basic usage

(Cmd use the following command line)

2. Install webpack

  (1) global mount

    $ npm install webpack -g

    (1) mounted locally

    I do not like global installed this way, because not all projects require webpack of. Usually we will Webpack installed to rely project, so that you can use the local version of the project Webpack.

    # 进入项目目录

    # 确定已经有 package.json,没有就通过 npm init 创建

     # 安装 webpack 依赖
     $ npm install webpack --save-dev
  (--Save-dev as a development will depend to install webpack. After the installation is successful, will be one more configuration package.json
    
    )
3. Install webpack-dev-server (it can provide many services in the development environment, such as starting a server, hot update, interface agent, etc.)
  $ npm install webpack-dev-server --save-dev
  After the installation is complete, the final package.json contents of the file:
  

If your devDependencies contains webpack and webpack-dev-server, Congratulations, you have successfully installed!

Guess you like

Origin www.cnblogs.com/ahaMOMO/p/11351493.html