grunt-contrib-connect 忽略任务选项



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

包.json

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

Grundfilesnippet:

// 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
在你的

第一个例子中,你的配置没有目标,在你的第二个例子中,它有一个目标"abc"。

添加一个目标可能应该有效,我认为目标甚至可能是空的!

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

相关内容

最新更新