baldore / open-browser-webpack-plugin

Opens a new browser tab when Webpack loads.
119 stars 27 forks source link

Why it open the browser twice? #21

Open asyncatt opened 7 years ago

asyncatt commented 7 years ago

first open http://localhost:7760/undefined and then open http://localhost:7760/client.

Here is my code :

new OpenBrowserPlugin({ url: `http://localhost:${devServer.port}/client` })
fangwentian commented 6 years ago

same issue with you

viunyrk commented 6 years ago

In my case it opens correctly, but 2 tabs. Here is my config `const browserConfig = { ...config, context: path.resolve(dirname, 'src', 'client'), entry: ['webpack-hot-middleware/client', 'babel-polyfill', './client.js'], output: { path: path.resolve(dirname, 'public'), filename: 'bundle.js', hotUpdateChunkFilename: 'hot/hot-update.js', hotUpdateMainFilename: 'hot/hot-update.json', publicPath: '/', }, module: { rules: [ { test: /.js$/, include: /src/, loader: 'babel-loader' }, { test: /^((?!bootstrap.min).)*.css$/, use: [{ loader: 'style-loader', // inject CSS to page }, { loader: 'css-loader', options: { modules: true, importLoaders: 1, localIdentName: '[path][name]__[local]--[hash:base64:5]' } }, { loader: 'postcss-loader', // Run post css actions options: { sourceMap: true, plugins () { // post css plugins, can be exported to postcss.config.js return [ require('postcss-cssnext')(), require('postcss-nesting')(), require('postcss-nested')(),

                        ];
                    }
                }
            }]
        }, {
            test: /bootstrap\.min\.css$/,
            use: ['style-loader', 'css-loader']
        },
    ],
},
plugins: [
    new webpack.DefinePlugin({
        __isBrowser__: 'true',
        NODE_ENV: JSON.stringify(NODE_ENV),
    }),
    new CleanWebpackPlugin(['public'], cleanOptions),
    new HtmlWebpackPlugin({
        template: `${__dirname}/src/index.html`,
        inject: 'body'
    }),
    new webpack.HotModuleReplacementPlugin(),
    ...(isDevMode ? [new OpenBrowserPlugin({ url: 'http://localhost:3000' })] : []),
],

};`