var config = require('./config');

var path = require('path'),
  webpack = require('webpack'),
  devServer = config.ip + ':' + config.port;

var escapeRegExpString = function(str) {
  return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
};

var pathToRegExp = function(p) {
  return new RegExp("^" + escapeRegExpString(p));
};

var fileNames = function(pathDir, paths) {
  return paths.map( function(stFileName) {
    return pathDir + stFileName;
  });
};

var getEntry = function(type) {
  var entry = {
    'vendor' : ['react', 'react-style', 'react-draggable', 'flux', 'page', 'object-assign', 'keymirror'],
    'app' : ['./app/index.jsx']
  };
  console.log(entry);
  return entry;
};

var getPlugins = function(type) {
  var arr = [];
  arr.push(new webpack.NoErrorsPlugin());
  arr.push(new webpack.optimize.DedupePlugin());
  arr.push(new webpack.optimize.OccurenceOrderPlugin());
  if ( type === 'production') {
    arr.push(new webpack.optimize.UglifyJsPlugin({ output : { comments : false } }));
  }
  arr.push(new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 20 }));
  arr.push(new webpack.optimize.CommonsChunkPlugin("vendor", "vendor.bundle.js", Infinity));
  return arr;
};

module.exports = {
  context : __dirname,
  entry : getEntry(config.env),
  devTool : 'eval',
  output : {
    path : __dirname + '/assets/',
    publicPath : '/assets/',
    filename : '[name].bundle.js',
    chunkFilename : '[hash]/js/[id].bundle.js'
  },
  module : {
    loaders : [
      { test: /\.jsx?$/, loaders: ['babel'], exclude: /node_modules/ },
      { test: /\.scss$/, loader: 'style!css!sass' }
    ],
    preloaders : [
      {
        test : /\.js$/,
        include : pathToRegExp(path.join(__dirname, "app")),
        loader : 'jshint-loader'
      }
    ]
  },
  resolve : {
    extensions : ['', '.js', '.jsx', '.css', '.scss'],
    modulesDirectories : ["web_loaders", "web_modules", "node_loaders", "node_modules"]
  },
  plugins : getPlugins(config.env)
};
var config = require('./config');

var path = require('path'),
  webpack = require('webpack'),
  devServer = config.ip + ':' + config.port;

var escapeRegExpString = function(str) {
  return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
};

var pathToRegExp = function(p) {
  return new RegExp("^" + escapeRegExpString(p));
};

var fileNames = function(pathDir, paths) {
  return paths.map( function(stFileName) {
    return pathDir + stFileName;
  });
};

var getEntry = function(type) {
  var entry = {
    'vendor' : ['react', 'react-style', 'react-draggable', 'flux', 'page', 'object-assign', 'keymirror'],
    'app' : ['./index.jsx']
  };
  console.log(entry);
  return entry;
};

var getPlugins = function(type) {
  var arr = [];
  arr.push(new webpack.NoErrorsPlugin());
  arr.push(new webpack.optimize.DedupePlugin());
  arr.push(new webpack.optimize.OccurenceOrderPlugin());
  if ( type === 'production') {
    arr.push(new webpack.optimize.UglifyJsPlugin({ output : { comments : false } }));
  }
  arr.push(new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 20 }));
  arr.push(new webpack.optimize.CommonsChunkPlugin("vendor", "vendor.bundle.js", Infinity));
  return arr;
};

module.exports = {
  context : __dirname,
  entry : getEntry(config.env),
  devTool : 'eval',
  output : {
    path : __dirname + '/assets/',
    publicPath : '/assets/',
    filename : '[name].bundle.js',
    chunkFilename : '[hash]/js/[id].bundle.js'
  },
  module : {
    loaders : [
      { test: /\.jsx?$/, loaders: ['babel'], exclude: /node_modules/ },
      { test: /\.scss$/, loader: 'style!css!sass' }
    ],
    preloaders : [
      {
        test : /\.js$/,
        include : pathToRegExp(path.join(__dirname, "app")),
        loader : 'jshint-loader'
      }
    ]
  },
  resolve : {
    extensions : ['', '.js', '.jsx', '.css', '.scss'],
    modulesDirectories : ["web_loaders", "web_modules", "node_loaders", "node_modules"]
  },
  plugins : getPlugins(config.env)
};
Change specification of index file used by wepback