grunt-contrib-connect ignores task options

117 views Asked by At

I have configured grunt-contrib-connect but the server did not stay alive:

package.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'
    ]);
});

When running task "server" the server start and stops, ignoring the options:

Running "server" task
Done, without errors.

But changing the config like:

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

Makes the task run "connect:abc" and take the options. Why the task default options are ignored?

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

There are 1 answers

0
hereandnow78 On BEST ANSWER

in your first example your config just has no target, in your second it has a target "abc".

adding a target should probably work, and i think the target could even be empty!:

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