如何使webpack开发服务器在端口80和0.0.0.0上运行以使其可公开访问? [英] How to make the webpack dev server run on port 80 and on 0.0.0.0 to make it publicly accessible?

查看:314
本文介绍了如何使webpack开发服务器在端口80和0.0.0.0上运行以使其可公开访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对整个 nodejs / reactjs 世界是陌生的,如果我的问题听起来很傻,那么我深表歉意.所以我在玩 reactabular.js .

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

每当我执行npm start时,它总是在localhost:8080上运行.

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

如何更改它以使其在0.0.0.0: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 does this setting.

还要补充一点-如果可能的话,如何使其在端口80上运行?

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

推荐答案

类似的方法对我有用.我猜这应该为您工作.

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

使用此命令运行webpack-dev

Run webpack-dev using this

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

并在webpack.config.js中设置

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.

使用此命令运行webpack-dev

Run webpack-dev using this

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

并在webpack.config.js中设置

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()]

这篇关于如何使webpack开发服务器在端口80和0.0.0.0上运行以使其可公开访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆