grunt-contrib-connect服务器无法连接到localhost

时间:2014-07-13 18:18:57

标签: gruntjs grunt-contrib-connect

我的Gruntfile:

...
connect: {
  server: {
    options: {
      port: 8000,
      hostname: 'localhost',
      base: '.'
    }
  }
}
...

然后,当我运行grunt connect时,我看到了这一点:

❯ grunt connect
  Running "connect:server" (connect) task
  Started connect web server on http://localhost:8000

  Done, without errors.
❯

那就是它。如果我到了我的localhost:8000。我看到chrome无法连接。

1 个答案:

答案 0 :(得分:3)

如果您想将 grunt-contrib-connect 用作开发服务器,请查看keepalive选项。

根据文件:

  

请注意,只要grunt正在运行,此服务器就会运行。一旦   grunt的任务已经完成,Web服务器停止。这种行为可以   使用 keepalive 选项进行更改,并且可以通过ad-hoc启用   像grunt connect:keepalive一样运行任务。

相关问题