Skip to content

open option doesn't work in API mode #1722

Closed
@guoyunhe

Description

@guoyunhe
  • Operating System: Linux
  • Node Version: 10.15.2
  • NPM Version: 6.9.0
  • 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

'use strict';

// our setup function adds behind-the-scenes bits to the config that all of our
// examples need
const { setup } = require('../../util');

module.exports = setup({
  context: __dirname,
  entry: ['./app.js', '../../../client/index.js?http://localhost:8080/'],
  output: {
    filename: 'bundle.js',
  },
});
// scripts/start.js
'use strict';

const Webpack = require('webpack');
const WebpackDevServer = require('../../../lib/Server');
const webpackConfig = require('./webpack.config');

const compiler = Webpack(webpackConfig);
const devServerOptions = Object.assign({}, webpackConfig.devServer, {
  open: true,
  stats: {
    colors: true,
  },
});
const server = new WebpackDevServer(compiler, devServerOptions);

server.listen(8080, '127.0.0.1', () => {
  console.log('Starting server on http://localhost:8080');
});

Expected Behavior

Running the script should open browser.

Actual Behavior

Browser is not opened.

For Bugs; How can we reproduce the behavior?

git clone [email protected]:guoyunhe/webpack-dev-server.git
cd webpack-dev-server
npm install
cd examples/api/simple
node server.js

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions