Question

I'm quite new to the bower / grunt / yeoman environment. I'm trying to customize the app generated by the default yeoman Webapp generator.

Basically when I launch grunt serve the default browser will be launched opening the url served by the grunt server. I'd like to specify in which browser the webapp should be opened but I had no luck.

These are the default options of the connect task (using grunt-contrib-connect) inside my gruntfile:

connect: {
        options: {
            port: 9000,
            open: true,
            livereload: 35729,
            // Change this to '0.0.0.0' to access the server from outside
            hostname: 'localhost',
        }

I've tried to add the field appName: 'Firefox' but I think this is not what I'm looking for. I guess the appName is used to specify how to lauch the default browser from the command line (e.g. with the open command), am I right?

Is it possible to specify the browser in grunt-contrib-connect or not at all? If not how should I accomplish this task? Maybe using grunt-open?

Thanks

Était-ce utile?

La solution

According to this commit in grunt-contrib-connect , the open option seems to be supported from v0.6.0. But the app generated webapp generator uses v0.5.0 by default.

So you need to upgrade it in package.json.

    "grunt-contrib-connect": "~0.7.1",

Then run npm install (and you can double-check with npm list | grep grunt-contrib-connect if v0.7.1 has been installed) and add the open option in Gruntfile.js.

    connect: {
        ...
        livereload: {
            options: {
                open: {
                    appName: 'Firefox'
                },
        ...

This works for me, so I hope this helps you too.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top