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

I was looking for her, I could not find anything related to the question.

I want this to be related to workflow issues. I set up a developer account on the chrome canary and would like to keep all the things related to development in this browser.

There is a place in the options devServer object where I can tell the webpack-dev server to open "Google Chrome Canary". I use a Mac if that matters.

+7
source share
4 answers

It looks like they added the ability to set the browser name in the open option in v2.8.0. Please note that, at least for some browsers, the browser name will depend on the OS (it seems to be passed directly to the opn package, so the same rules apply):

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

In addition to searching on Google, you can also search in the package repository. It takes some time and β€œpopularity” before Google shows it on top of other matches.

+7
source

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

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

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

In webpack.config.js:

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

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

+3
source

I'm not sure if I understood your question correctly, but browserSyncPlugin has a "--browser" which you can pass, for example, "Chrome".

Please note that I did not find what exactly you should specify as the value, but the chrome seems to work on Windows 7.

0
source

For MacOS:

  1. Do not use the devServer property in webpack.config.js
  2. Use this in package.json: "start": "webpack-dev-server --open 'google chrome'"
0
source

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


All Articles