HiveBrain v1.2.0
Get Started
← Back to all entries
snippetjavascriptreactCritical

How to make the webpack dev server run on port 80 and on 0.0.0.0 to make it publicly accessible?

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
accessiblethedevandpubliclywebpackrunserverhowport

Problem

I am new to the whole nodejs/reactjs world so apologies if my question sounds silly. I am currently playing around with reactabular.js.

Whenever I do a npm start it always runs on localhost:8080.

How do I change it to run on 0.0.0.0:8080 to make it publicly accessible? I have been trying to read the source code in the above repo but failed to find the file which sets this setting.

Also, to add to that - how do I make it run on port 80 if that is at all possible?

Solution

Something like this worked for me. I am guessing this should work for you.

Run webpack-dev using this

webpack-dev-server --host 0.0.0.0 --port 80


And set this in webpack.config.js

entry: [
    'webpack-dev-server/client?http://0.0.0.0:80',
     config.paths.demo
 ]


Note If you are using hot loading, you will have to do this.

Run webpack-dev using this

webpack-dev-server --host 0.0.0.0 --port 80


And set this in webpack.config.js

entry: [
    'webpack-dev-server/client?http://0.0.0.0:80',
    'webpack/hot/only-dev-server',
     config.paths.demo
 ],

....
plugins:[new webpack.HotModuleReplacementPlugin()]

Code Snippets

webpack-dev-server --host 0.0.0.0 --port 80
entry: [
    'webpack-dev-server/client?http://0.0.0.0:80',
     config.paths.demo
 ]
webpack-dev-server --host 0.0.0.0 --port 80
entry: [
    'webpack-dev-server/client?http://0.0.0.0:80',
    'webpack/hot/only-dev-server',
     config.paths.demo
 ],

....
plugins:[new webpack.HotModuleReplacementPlugin()]

Context

Stack Overflow Q#33272967, score: 294

Revisions (0)

No revisions yet.