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

编程入门 行业动态 更新时间:2024-10-04 03:32:18

grunt connect 退出<a href=https://www.elefans.com/category/jswz/34/1771014.html style=而不是提供本地文件"/>

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

我有一个 Gruntfile.js,它只包含两个任务:第一个解析/生成文件,第二个,

grunt-contrib-connect
,启动网络服务器:

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
的文档了吗?

According to the document.You need to set

keepalive
true if want keep alive the server after grunt tasks complete.

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

无限期地保持服务器活动。请注意,如果启用此选项,则此任务之后指定的任何任务都不会运行。默认情况下,一旦 grunt 的任务完成,Web 服务器就会停止。此选项会更改该行为。

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

更多推荐

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

本文发布于:2024-05-31 05:18:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1771316.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:而不是   本地文件   grunt   connect

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!