webpack-dev-server to specify the default Open chrome browser way

webpack-dev-server open the correct way to specify the browser

2019.03.26 00:14:44 read 835 words 201

Mac computer with development, the default browser is Safari, but is not convenient debugging.

Creating a project, webpack-dev-server default setting is to open the default browser to use vue-cli, how to change? Ever find a degree of your mother, a bunch of search results:

The results are basically like this:

image

Modified in accordance with, and then the eggs, but to give a message, webpack-dev-server opn open a browser is implemented, then go webpack-dev-server see the following source code bin / webpack-dev-server.js :


open: {

    type: 'string',

    describe: 'Open the default browser, or optionally specify a browser name'

  },

Look  https://www.npmjs.com/package/opn  document:


const opn = require('opn');

// Opens the image in the default image viewer

opn('unicorn.png').then(() => {

    // image viewer closed

});

// Opens the url in the default browser

opn('http://sindresorhus.com');

// Specify the app to open in

opn('http://sindresorhus.com', {app: 'firefox'});

// Specify app arguments

opn('http://sindresorhus.com', {app: ['google chrome', '--incognito']});

It seems to understand modify the code:

Modify: myvuetest / package.json file


  "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js" 

Read:


"dev": "webpack-dev-server --inline --progress --open 'google chrome' --config build/webpack.dev.conf.js" 

Get.

Published 293 original articles · won praise 27 · views 120 000 +

Guess you like

Origin blog.csdn.net/gwdgwd123/article/details/102524009