【问题标题】:grunt-contrib-connect ignores task optionsgrunt-contrib-connect 忽略任务选项
【发布时间】:2014-11-21 07:36:00
【问题描述】:

我已经配置了 grunt-contrib-connect 但服务器没有保持活动状态:

package.json

{
  "name": "my-project-name",
  "version": "0.1.0",
  "devDependencies": {
    "grunt": "^0.4.5",
    "grunt-contrib-connect": "^0.9.0",
  }
}

Grundfilesn-p:

// Project configuration.
grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    connect: {
        options: {
            port: 9000,
            base: 'src/main/webapp',
            keepalive: 'true'
        }
    }
});

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

grunt.registerTask('server', function () {
    grunt.task.run([
        'connect'
    ]);
});

当运行任务“服务器”时,服务器启动和停止,忽略选项:

Running "server" task
Done, without errors.

但是像这样改变配置:

grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    connect: {
        abc:{
            options: {
                port: 9000,
                base: 'src/main/webapp',
                keepalive: 'true'
            }
        }
    }
});

使任务运行“connect:abc”并选择选项。 为什么忽略任务默认选项?

Running "server" task
Running "connect:abc" (connect) task
Waiting forever...
Started connect web server on http://0.0.0.0:9000

【问题讨论】:

    标签: javascript gruntjs config grunt-contrib-connect


    【解决方案1】:

    在您的第一个示例中,您的配置没有target,在您的第二个示例中,它有一个目标“abc”。

    添加一个目标应该可以工作,我认为目标甚至可以是空的!:

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        connect: {          
            options: {
                port: 9000,
                base: 'src/main/webapp',
                keepalive: true
            },
            abc: {}
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2015-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-01
      • 2017-06-12
      • 1970-01-01
      • 2014-04-16
      • 1970-01-01
      相关资源
      最近更新 更多