【问题标题】:Grunt connect not living long enough to allow me to test itGrunt connect 没有足够长的时间让我测试它
【发布时间】:2015-03-09 13:55:52
【问题描述】:

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

【问题讨论】:

    标签: gruntjs grunt-contrib-connect


    【解决方案1】:

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

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

    【讨论】:

    • 谢谢,但为什么要加keepalive?这不是很明显吗?谁会想要一个运行 3 秒的服务器?
    猜你喜欢
    • 1970-01-01
    • 2019-03-14
    • 1970-01-01
    • 2022-09-28
    • 2022-01-06
    • 1970-01-01
    • 2016-03-02
    • 1970-01-01
    • 2023-03-18
    相关资源
    最近更新 更多