Grunt连接的时间不够长,无法让我测试它

时间:2015-03-09 13:55:52

标签: gruntjs grunt-contrib-connect

当我尝试使用Grunt为我创建服务器时,它会很快关闭,并且不会让我更改我的浏览器并进行测试。

这是我的整个Grunt文件:

module.exports = function (grunt) {
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.initConfig({
        connect: {
            serve: {
                options: {
                    port: 8081,
                    base: '/',
                    hostname: '*',
                    debug: true
                }
            }
        }
    });
    grunt.registerTask('default', ['connect']);
}

当我运行它时,它可以正常运行:

C:\Users\Imray\my-sandbox>grunt
Running "connect:keepalive" (connect) task
Started connect web server on http://0.0.0.0:8000

Running "connect:serve" (connect) task
Started connect web server on http://0.0.0.0:8081

1 个答案:

答案 0 :(得分:0)

您有keepalive专用的设置:

grunt.initConfig({
        connect: {
            serve: {
                options: {
                    keepalive: true,
                    port: 8081,
                    base: '/',
                    hostname: '*',
                    debug: true
                }
            }
        }
    });