'use strict';

/**
 * Created by x on 11/23/15.
 */
var path = require('path');
var webpack = require('webpack');
var os = require('os');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.config.dev');
var pathToBuild = path.resolve(__dirname, 'www');
var IPv4
for(var i=0;i<os.networkInterfaces().en0.length;i++){
    if(os.networkInterfaces().en0[i].family=='IPv4'){
        IPv4=os.networkInterfaces().en0[i].address;
    }
}
console.log(IPv4)
//import config from './webpack.dev.config';
var open = require('open');
const opts_config = {
    port: 8676
}
var compiler = webpack(config);
/***
 * publicPath 启动服务的资源路径
 */
var server = new WebpackDevServer(compiler, {
    compress: true,
    hot: true,
    public:IPv4,
    publicPath: config.output.publicPath,
    open: true,
    inline: true,
   /* proxy: {
        "/": {
            target: "http://192.168.1.102:8000",
            secure: false
        }
    }*/
})
server.listen(9090, '0.0.0.0', function (err, result) {
    if (err) {
        console.log(err);
    }
    console.log(`Listening at ${IPv4}:9090/index.html`);
    open(`http://${IPv4}:9090/index.html`);
});
    contentBase: path.resolve(__dirname,'www'),