Skip to content

[Modification] Allow passing args to devServer.open #1769

Closed
@dangreenisrael

Description

@dangreenisrael
  • Operating System: Mac OS
  • Node Version: 8.15.0
  • NPM Version: 6.4.1
  • webpack Version: 4.29.6
  • webpack-dev-server Version: 3.3.0
  • This is a bug
  • This is a modification request

Code

// webpack.config.js
devServer: {
  open: ['google chrome', '--incognito']
}

Expected Behavior

devServer.open accepts an array of strings as per the as per the open documentation
https://www.npmjs.com/package/open (formerly https://www.npmjs.com/package/opn)

In this case, open chrome in an incognito tab,

Actual Behavior

Anything other than a string is dropped

if (options.open) {
let openOptions = {};
let openMessage = 'Unable to open browser';
if (typeof options.open === 'string') {
openOptions = { app: options.open };
openMessage += `: ${options.open}`;
}
open(uri + (options.openPage || ''), openOptions).catch(() => {
log.warn(
`${openMessage}. If you are running in a headless environment, please do not use the --open flag`
);
});
}

For Features; What is the motivation and/or use-case for the feature?

We would like to automatically open incognito tabs for our devs, as part of our setup and teardown for webpack-dev-server is updating the hosts file, and chrome caches DNS.

If this is something that would be accepted I could open a PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions