Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack Dev Server: Support multiple hosts

Webpack Dev Server defaults to using localhost as its host. This can easily be overwritten by specifying the host parameter with either a hostname or IP address. However, it seems that you can only specify one. For example, if I specify the IP Address 192.168.1.20, then it stops responding to localhost. How can I configure Webpack Dev Server to listen to multiple hosts?

like image 956
Johnny Oshika Avatar asked Nov 16 '15 04:11

Johnny Oshika


People also ask

What is the use of webpack-dev-server?

webpack-dev-server is Webpack's officially supported CLI-based tool for starting a static server for your assets. While you don't need any CLI tools to use Webpack, webpack-dev-server gives you a single command that starts a static server with built-in live reload.

How does Webpack Dev middleware work?

Webpack Dev Middleware is middleware which can be mounted in an express server to serve the latest compilation of your bundle during development. This uses webpack 's Node API in watch mode and instead of outputting to the file system it outputs to memory.

What is Contentbase in webpack?

Exists only in webpack-dev-server. It's only needed if you want to serve static files. For example, you want a folder of mp4 vacation movies to be available for the app, but you don't want to run them through the bundle, because that would be silly.

What port does webpack-dev-server use?

webpack-dev-server on port 8080 .


1 Answers

0.0.0.0 is the catch-all host and will bind to all hosts.

Example:

  devServer: {
    port: 3000,
    host: '0.0.0.0'
  }

Source: https://github.com/webpack/webpack-dev-server/issues/400#issuecomment-201213206

like image 145
Johnny Oshika Avatar answered Oct 09 '22 15:10

Johnny Oshika