Webpack - Dev Server

> (World Wide) Web - (W3|WWW) > Web - Building and Shipping > Web - WebPack

1 - About

The WebPack dev is a little Node.js Express web server that implements live-reloading

Advertising

3 - Starting

3.1 - Manually

In the root directory (where your WebPack - webpack.config.js is), run:

node_modules/.bin/webpack-dev-server

This will start a server, listening on connections from localhost on port 8080.

3.2 - As Node Script

As npm script

{
   // ............
  "scripts": {
    "start": "webpack-dev-server"
  },
  "dependencies": {
    "d3": "^4.10.2"
  },
  "devDependencies": {
    "webpack": "^3.6.0",
    "webpack-dev-server": "^2.8.2"
  }
}

Then:

npm start

4 - Configuration

webpack.config.js
const path = require('path');
 
module.exports = {
    devServer: {
        contentBase: path.join(__dirname, "dist"),
        compress: true,
        port: 9000
    }
}

where a web server will be started:

  • in the dist directory
  • on the port 9000
  • with compression on.
Advertising

5 - Documentation / Reference