Skip to content

Open browser after devserver compilation  #7945

Open
@darajava

Description

@darajava

Is your proposal related to a problem?

When running npm run start, the browser opens almost immediately leaving a blank page for a good few seconds before the code is actually compiled.

Describe the solution you'd like

It would be better if the browser only gets invoked after compilation has passed.

Additional context

This can be achieved easily with WebpackDevServer hooks as with the following snippet:

let compiledOnce = false;
// After WebpackDevServer compiles the bundle, open it in the browser.
compiler.hooks.afterCompile.tap(appName, () => {
  if (!compiledOnce) {
    openBrowser(urls.localUrlForBrowser);
  }
  compiledOnce = true;
});

(Maybe someone can help me with that ugly boolean variable that is required to prevent new tabs when hot reloading)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions