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

后端 未结 13 1305
时光取名叫无心
时光取名叫无心 2020-11-30 17:36

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

Wh

13条回答
  •  野性不改
    2020-11-30 17:56

    Following worked for me -

    1) In Package.json add this:

    "scripts": {
        "dev": "webpack-dev-server --progress --colors"
    }
    

    2) In webpack.config.js add this under config object that you export:

    devServer: {
        host: "GACDTL001SS369k", // Your Computer Name
        port: 8080
    }
    

    3) Now on terminal type: npm run dev

    4) After #3 compiles and ready just head over to your browser and key in address as http://GACDTL001SS369k:8080/

    Your app should hopefully be working now with an external URL which others can access on the same network.

    PS: GACDTL001SS369k was my Computer Name so do replace with whatever is yours on your machine.

提交回复
热议问题