Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to configure webpack-dev-server to open a specified browser window ? For example Chrome Canary on mac

I have googled about it, could not find anything related to the question.

The reason I want this is for workflow issues. I have setup a developer account on chrome canary and would like to keep all things related to development to that browser.

In devServer options object, is there a place where I can tell webpack-dev-server to open "Google Chrome Canary". I use Mac, if that makes a difference.

like image 941
frank3stein Avatar asked Mar 19 '17 15:03

frank3stein


3 Answers

Looks like they added a possibility to set a browser name in open option in v2.8.0. Note that at least for some browsers browser name will be OS-specific (it seems to be passed directly to opn package, therefore, same rules):

https://github.com/webpack/webpack-dev-server/pull/825

In addition to googling, you may want to search in package's repository Issues as well. Takes some time and "popularity" before google shows it on top of other matches.

like image 86
Dmitry Gonchar Avatar answered Oct 09 '22 12:10

Dmitry Gonchar


This is how I fixed the issue. In package.json:

"start": "webpack-dev-server --config webpack.dev.js --open chrome",

of course, you can use webpack.config.js instead webpack.dev.js

In webpack.config.js:

devServer: {
        ...
        open: 'chrome'
      },

This is for Google Chrome, so just use any other browser name.

like image 28
CrowScript Avatar answered Oct 09 '22 12:10

CrowScript


For MacOS:

  1. Don't use the devServer property in webpack.config.js
  2. Use this in package.json: "start": "webpack-dev-server --open 'google chrome'"
like image 2
ruben Avatar answered Oct 09 '22 12:10

ruben