Grunt-contrib-connect: how to start the server in the specified browser

I am completely new to the arbor environment / grunt / yeoman . I am trying to customize the application created by the default Webapp generator.

Basically, at startup grunt serve, the default browser starts, opening the URL served by the grunt server. I would like to indicate in which browser the webapp should open, but I had no luck.

These are the default settings for the connection task (using grunt-contrib-connect) inside my grunt file:

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

I tried to add a field appName: 'Firefox', but I think this is not what I am looking for. I suppose it is appNameused to indicate how to use the default browser from the command line (for example, using the command open), am I correct?

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

thank

+4
source share
1 answer

According to this commit in grunt-contrib-connect, the option openseems to be supported since v0.6.0. But the Webapp generator created by the application uses v0.5.0 by default.

, package.json.

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

npm install ( npm list | grep grunt-contrib-connect, v0.7.1 ) open Gruntfile.js.

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

, , .

+5

Source: https://habr.com/ru/post/1536572/


All Articles