我的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无法连接。
答案 0 :(得分:3)
如果您想将 grunt-contrib-connect 用作开发服务器,请查看keepalive选项。
根据文件:
请注意,只要grunt正在运行,此服务器就会运行。一旦 grunt的任务已经完成,Web服务器停止。这种行为可以 使用 keepalive 选项进行更改,并且可以通过ad-hoc启用 像
grunt connect:keepalive
一样运行任务。