vue-cli icon indicating copy to clipboard operation
vue-cli copied to clipboard

Setting devServer.open='chrome' does not work

Open niaodan2b opened this issue 8 years ago • 4 comments

Version

3.0.0-rc.12

Node and OS info

Node 8.9.4 / npm 5.5.1 / Windows 10

Steps to reproduce

create a project with default settings, and set devServer:{open:'chrome'} in vue.config.js, then do npm run serve.

What is expected?

chrome automatically opened

What is actually happening?

system default browser opened


In the webpack documentation, the devServer.open option allows passing a string to specify which browser to open. That used to work when using vue-cli 2.x.

niaodan2b avatar Aug 10 '18 07:08 niaodan2b

Vue CLI uses a different open implementation to avoid opening duplicated windows, so we need to document that.

yyx990803 avatar Aug 10 '18 11:08 yyx990803

@yyx990803 so how could we open another browser, instead of the default one.

igorer88 avatar Aug 18 '19 21:08 igorer88

I dug through the code and figured out I needed to define environment variable BROWSER.

export BROWSER="Google Chrome"

daviesdoclc avatar Nov 27 '19 15:11 daviesdoclc

@yyx990803 why not get browser from devServer.open, but use process args instead? I think this config would better to compatible with original webpack-dev-server, like the docs wrote, thanks. https://cli.vuejs.org/config/#devserver

function getBrowserEnv () {
  // Attempt to honor this environment variable.
  // It is specific to the operating system.
  // See https://github.com/sindresorhus/open#app for documentation.
  const value = process.env.BROWSER

tweet avatar Jan 07 '20 03:01 tweet