gpt4 book ai didi

javascript - grunt connect 退出而不是提供本地文件

转载 作者:行者123 更新时间:2023-11-28 19:20:55 25 4
gpt4 key购买 nike

我有一个以下 Gruntfile.js,其中仅包含两个任务:第一个任务解析/生成文件,第二个任务 grunt-contrib-connect 启动 Web 服务器:

module.exports = function(grunt) {

grunt.initConfig({
aglio: {
docs: {
files: {
'index.html': 'api.md',
},
options: {
theme: "slate"
}
}
},
connect: {
server: {
options: {
port: 9001,
hostname: 'localhost',
}
}
}
});

grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-aglio');

grunt.registerTask('default', ['aglio', 'connect']);
};

问题是服务器默默退出,我不知道为什么。在控制台中,它看起来像这样:

tducin@tducin-home:~/Workspace/duck-blueprint$ grunt
Running "aglio:docs" (aglio) task
>> Written to index.html

Running "connect:server" (connect) task
Started connect web server on http://localhost:9001

Done, without errors.

有人可以指出我的 connect 任务配置有什么问题吗?

最佳答案

您阅读过 grunt-contrib-connect 的文档吗?

根据文档。如果希望在 grunt 任务完成后保持服务器处于事件状态,则需要将 keepalive 设置为 true。

connect: {
server: {
options: {
port: 9001,
hostname: 'localhost',
keepalive : true
}
}

Keep the server alive indefinitely. Note that if this option is enabled, any tasks specified after this task will never run. By default, once grunt's tasks have completed, the web server stops. This option changes that behavior.

https://github.com/gruntjs/grunt-contrib-connect/blob/master/README.md

关于javascript - grunt connect 退出而不是提供本地文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28933018/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com