Closed wklc2015 closed 8 years ago
when i use open browser webpack plugin, it is ok, but it open two browser tab, I didn't know why, I check my webpack.config.js, I think is ok.
there is my config:
"use strict"; var webpack = require('webpack'); var path = require('path'); var WebpackDevServer = require('webpack-dev-server'); var HtmlwebpackPlugin = require('html-webpack-plugin'); var OpenBrowserPlugin = require('open-browser-webpack-plugin'); var UglifyJsPlugin = webpack.optimize.UglifyJsPlugin; var settings = require('./settings.js'); var env = process.env.WEBPACK_ENV; var plugins = [ new webpack.NoErrorsPlugin() ]; if (env === 'build') { plugins.push(new UglifyJsPlugin({ minimize: true })); } else if (env === 'dev') { plugins.push( new OpenBrowserPlugin({ url: 'http://' + settings.server.host + ':' + settings.server.port }) ); } var config = { entry: { app: settings.js.src, vender: [] }, output: { path: path.join(__dirname, settings.js.dist), filename: '[name].min.js', publicPath: __dirname + '/dist' }, module: { loaders: [{ test: /\.js[x]?$/, exclude: /node_modules/, loader: ['babel'], query: { presets: ['es2015', 'react'] }, include: path.join(__dirname, '.') }, { test: /\.css$/, loader: 'style-loader!css-loader' }, { test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192' }] }, resolve: { extensions: ['', '.js', '.jsx'], alias: { } }, plugins: plugins }; var port = settings.server.port; var host = settings.server.host; if (env === 'dev') { new WebpackDevServer(webpack(config), { contentBase: './dist', hot: true, debug: true }).listen(port, host, function (err) { if (err) { console.log(err); } }); console.log('----------------------------------------------------------'); console.log('Local web server runs at http://' + host + ':' + port); console.log('----------------------------------------------------------'); } module.exports = config;
Is there any wrong in my config?
Hmmm I have to check... Try setting just open browser plugin and see the result. It can be a incompatibility with webpack.NoErrorsPlugin.
when i use open browser webpack plugin, it is ok, but it open two browser tab, I didn't know why, I check my webpack.config.js, I think is ok.
there is my config:
Is there any wrong in my config?