[英]Webpack-dev-server live update in Codeanywhere
I'd love to speed up my dev / test process on Codeanywhere. 我很想加快在Codeanywhere上的开发/测试过程。
Codeanywhere's dev boxes give you some random URL to use for your host "application" (ie: index.html) like this: Codeanywhere的开发箱为您提供了一些随机URL,可用于您的主机“应用程序”(例如:index.html),如下所示:
http://preview.[really-long-hash].box.codeanywhere.com/build/
Not sure how to get from there to the webpack-dev-server if it is running. 如果运行,则不确定如何从那里到达webpack-dev-server。 Is there a basic configuration that I'm missing? 我是否缺少基本配置?
In all the Webpack tutorials, if you're running it locally, you would access the running dev server like this : http://localhost:8080
but http://preview.[really-long-hash].box.codeanywhere.com:8080
just shows an error message from Codeanywhere. 在所有Webpack教程中,如果您在本地运行它,则可以像这样访问正在运行的开发服务器: http://localhost:8080
但http://preview.[really-long-hash].box.codeanywhere.com:8080
仅显示来自Codeanywhere的错误消息。
When launching the dev-server, you must configure its host IP to 0.0.0.0
using the host
option. 启动dev-server时,必须使用host
选项将其主机IP配置为0.0.0.0
。 Then, on codeanywhere, you can access it from http://preview.[really-long-hash].box.codeanywhere.com:8080
. 然后,在codeanywhere上,您可以从http://preview.[really-long-hash].box.codeanywhere.com:8080
访问它。
One additional note is that if your build folder is anything other than the root of the folder on which you invoke webpack-dev-server, you should also specify it using the content-base
option. 还有一点需要注意的是,如果您的构建文件夹不是调用webpack-dev-server的文件夹的根目录,则还应该使用content-base
选项指定它。
webpack-dev-server --devtool eval --host 0.0.0.0 --progress --colors --hot --content-base build
Note that if you get sick of typing this every time, configure an npm
script by editing your package.json
file and adding an entry into scripts
, eg: 请注意,如果您每次都讨厌键入此命令,请通过编辑package.json
文件并将条目添加到scripts
配置npm
scripts
,例如:
"main": "main.js",
"scripts": {
"test" : "echo \"Error: no test specified\" && exit 1",
"build" : "webpack --progress -colors",
"dev-server" : "webpack-dev-server --devtool eval --host 0.0.0.0 --progress --colors --hot --content-base build"
},
"repository": {
"type": "git",
etc... 等等...
All web servers on codeanywhere should be set to respond to 0.0.0.0:Port (0.0.0.0:8080 in your case). 应将codeanywhere上的所有Web服务器都设置为响应0.0.0.0:Port(在您的情况下为0.0.0.0:8080)。 You may need to configure your webapp so it doesn't point to localhost instead. 您可能需要配置您的webapp,以便它不会指向localhost。
After you start your webapp, you can view your web at http://preview.[really-long-hash].box.codeanywhere.com:8080 启动Web应用程序后,您可以在http:// preview。[really-long-hash] .box.codeanywhere.com:8080上查看您的网站。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.