Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get access to webpack-dev-server with external IP

I've got my simple login website fully coded and functional on the webpack dev server. how can i display it with my external IP? I've already port forwarded my router on port 9000 but when i tried www.myIp:portnumber its not working. Below is my webpack config for the webpack dev server.

//Webpack config
module.exports = {
  entry: './app/main.js',
  output: {
    path: './app',
    filename: 'bundle.js'
  },
  devServer: {
    inline: true,
    contentBase: './app',
    port: 9000
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel'
      }
    ]
  }
}
like image 644
Eric Avatar asked Jun 07 '17 21:06

Eric


People also ask

What port is the default where the webpack-dev-server will run?

Answer : D) 8080 is the default where webpack-dev-server runs.

What is webpack proxy?

webpack-dev-server can proxy some requests to others servers. This might be useful for developing API client when you want to send requests to same domain. Proxy is configured via proxy parameter.

What is devServer?

devServer.client Allows to set log level in the browser, e.g. before reloading, before an error or when Hot Module Replacement is enabled. webpack.config.js module.


1 Answers

Set the host property:

devServer: {
    inline: true,
    contentBase: './app',
    port: 9000,
    host: '0.0.0.0'
  }

https://webpack.js.org/configuration/dev-server/#devserver-host-cli-only

like image 80
cgatian Avatar answered Nov 15 '22 04:11

cgatian