Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run grunt server with various browsers

Tags:

gruntjs

yeoman

Is it possible to specify a particular browser (besides the OS' default) in the gruntfile or at the command prompt? E.g. "grunt server firefox" or the like. My default browser is Chrome, but I want to test/develop my site in multiple browsers. I am using GruntJS within Yeoman.

Bryan

like image 760
bk11425 Avatar asked Jul 02 '13 16:07

bk11425


2 Answers

Quick Answer

In Gruntfile.js you can add an app parameter:

open: {
  server: {
    url: 'http://localhost:<%= connect.options.port %>',
    app: 'firefox'
  }
},

Pull request: https://github.com/jsoverson/grunt-open/pull/7

Commit: https://github.com/GabLeRoux/grunt-open/commit/6f2c7069767e58160ec96aaaa8fa20ed210ba183


Command Line Parameters

It is possible to pass command line parameters in the app string, such as app: "chromium-browser --incognito" - @bk11425

like image 111
slamborne Avatar answered Sep 18 '22 18:09

slamborne


From the documentation of grunt connect: https://github.com/gruntjs/grunt-contrib-connect

You can use:

    open: {
        target: 'http://localhost:8000', // target url to open
        appName: 'open', // name of the app that opens, ie: open, start, xdg-open
        callback: function() {} // called when the app has opened
    }

i.e. appName: 'Google Chrome'

like image 28
agfa555 Avatar answered Sep 19 '22 18:09

agfa555