open browser when webpack loads
# npm
npm install webpack-open-browser -D
# yarn
yarn add webpack-open-browser -D
const { WebpackOpenBrowser } = require('webpack-open-browser');
const commonConfig = {
plugins: [
// open http://localhost:3000 in default browser
new WebpackOpenBrowser({ url: 'http://localhost:3000' }),
// more options
// specify firefox to open
new WebpackOpenBrowser({ url: 'http://localhost:3000', browser: 'firefox' }),
// delay 3 seconds
new WebpackOpenBrowser({ url: 'http://localhost:3000', delay: 3 * 1000 }),
// By default, this plugin only works when no compile error
new WebpackOpenBrowser({ url: 'http://localhost:3000', ignoreErrors: true }),
// You can set a group of option to open multiple urls in multiple browsers
new WebpackOpenBrowser([
{ url: 'http://localhost:3000', browser: 'chrome' },
{ url: 'http://localhost:3000', browser: 'firefox' },
]),
],
};