0

当我尝试使用 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
4

1 回答 1

0

您有keepalive专门用于此的设置:

grunt.initConfig({
        connect: {
            serve: {
                options: {
                    keepalive: true,
                    port: 8081,
                    base: '/',
                    hostname: '*',
                    debug: true
                }
            }
        }
    });
于 2015-03-09T14:42:08.863 回答