Webpack launch browser automatically

swelet picture swelet · Oct 24, 2015 · Viewed 37.3k times · Source

Gulp + live reload serves up my content on localhost and (here's what I'm after) launches the browser automatically at the server url whenever i run the gulp command (i.e I don't have to click the browser icon and navigate to the url manually). Can this be done in Webpack too?

I've tried a plugin called open-browser-webpack-plugin, but I could not get it to work.

Answer

HDave picture HDave · Sep 28, 2016

For webpack version 2.x, you just add --open open to the CLI as documented here:

https://webpack.js.org/configuration/dev-server/#devserver-open

Alternatively, add the following config to your webpack.config.js:

devServer: {
  open: true
}