Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open browser after devserver compilation #7945

Open
darajava opened this issue Nov 7, 2019 · 2 comments
Open

Open browser after devserver compilation #7945

darajava opened this issue Nov 7, 2019 · 2 comments

Comments

@darajava
Copy link

darajava commented Nov 7, 2019

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)

@darajava
Copy link
Author

darajava commented Nov 7, 2019

I can't seem to create a PR for this, but it's ready to go in a branch if people think it's a good idea!

@darajava
Copy link
Author

darajava commented Dec 9, 2019

@gaearon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant