#!/usr/bin/env node

// Local version replaces global one
try {
	var localWebpackDevServer = require.resolve(path.join(process.cwd(), "node_modules", "webpack-dev-server", "bin", "webpack-dev-server.js"));
	if(__filename !== localWebpackDevServer) {
		return require(localWebpackDevServer);
	}
} catch(e) {}

var path = require("path");
var Server = require("../lib/Server");
var webpack = require("webpack");

var optimist = require("optimist")

	.usage("webpack-dev-server " + require("../package.json").version + "\n" +
			"Usage: https://github.com/webpack/docs/wiki/webpack-detailed-usage")

	.boolean("colors").alias("colors", "c").describe("colors")

	.boolean("info").describe("info").default("info", true)

	.boolean("quiet").describe("quiet")

	.string("content-base").describe("content-base", "A directory or URL to serve HTML content from.")

	.describe("port", "The port").default("port", 8080);

require("webpack/bin/config-optimist")(optimist);

var argv = optimist.argv;

var options = {};

var wpOpt = require("webpack/bin/convert-argv")(optimist, argv, { outputFilename: "/bundle.js" });

options.publicPath = wpOpt.output.publicPath || "";
options.outputPath = wpOpt.output.path = "/";
options.filename = wpOpt.output.filename;
options.hot = argv["hot"];

if(options.publicPath[0] !== "/")
	options.publicPath = "/" + options.publicPath;

if(argv["content-base"]) {
	options.contentBase = argv["content-base"];
	if(!/^(https?:)?\/\//.test(options.contentBase))
		options.contentBase = path.resolve(options.contentBase);
} else {
	options.contentBase = process.cwd();
}

if(argv["colors"])
	options.stats = { colors: true };

if(!argv["info"])
	options.noInfo = true;

if(argv["quiet"])
	options.quiet = true;

new Server(webpack(wpOpt), options).listen(argv.port, function(err) {
	if(err) throw err;
	console.log("http://localhost:" + argv.port + "/webpack-dev-server/");
	console.log("webpack result is served from " + options.publicPath);
	console.log("content is served from " + options.contentBase);
});
@@ -1116,24 +1116,40 @@
 publicPath =
+ wpOpt.output &&
  wpOpt.outpu
@@ -1192,28 +1192,8 @@
 th =
- wpOpt.output.path =
  %22/%22
@@ -1229,18 +1229,163 @@
 tput
-.filename;
+ && wpOpt.output.filename;%0Aif(Array.isArray(wpOpt)) %7B%0A%09wpOpt.forEach(function(wpOpt) %7B%0A%09%09wpOpt.output.path = %22/%22;%0A%09%7D);%0A%7D else %7B%0A%09wpOpt.output.path = %22/%22;%0A%7D
 %0Aopt

support an array in webpack.config.js