2

我的 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.
❯

然后就是这样。如果我到达我的本地主机:8000。我看到 chrome 无法连接。

4

1 回答 1

3

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

根据文档:

请注意,该服务器仅在 grunt 运行时运行。一旦 grunt 的任务完成,Web 服务器就会停止。可以使用keepalive选项更改此行为,并且可以通过运行类似grunt connect:keepalive.

于 2014-07-13T19:46:48.697 回答