This blog main record is I in the process of learning webpack3.x problems (although these days 4.0 just came out, but I would first learn 3.x it)
1, the configuration file can be used Webpack service and hot update, the steps are as follows:
① First Download: webpack-dev-server
CNPM Install Webpack-dev-server--save-dev
② Configuration Webpack.config.js
Module.exports = { //config Portal file entry:{},/ /config Export file output:{}, //config module: Mainly parsing CSS and image conversion compression functions module:{}, //configure plug-in plugins:[], //Configure development Services features devserver:{ //Set BASIC directory Structure contentbase: Path.resolve (__dirname, ' dist '), //Set the IP address of the server, you can use the IP address, or you can use localhost host: ' localhost ', // Server-side compression whether to turn on compress:true, //Configure service port ha port:2018 } }
③ Modifying Package.json files
"Scripts": { "server": "Webpack-dev-server" //Modify this location },
④ Open Terminal: win+r,cmd, switch to project directory, run: NPM run server
NPM Run Server
The following problems are encountered:
* Problem Description: I am currently using the Webpack is 3.6.0 version, the download of Webpack-dev-server is 3.1.0 version (the latest version at this time), because this version is too high to elicit this problem, the solution is to re-download a lower version of the Webpack-dev-ser ver, I downloaded the 2.8.2 version of the
CNPM i-d [email protected]
Problems encountered during the course of learning webpack3.x