var webpack = require('webpack');
var BundleTracker = require('webpack-bundle-tracker');
var path = require("path");

module.exports = {
  context: __dirname,
  
  entry: [
    'webpack-dev-server/client?http://0.0.0.0:3000', // WebpackDevServer host and port
    'webpack/hot/only-dev-server',
    './ditto/static/chat/js/base.js',
  ],
  
  output: {
    path: path.resolve('./ditto/static/bundles/'),
    filename: "[name]-[hash].js",
    publicPath: 'http://localhost:3000/assets/bundles/', // Tell django to use this URL to load packages and not use STATIC_URL + bundle_name
  },

  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loaders: ["react-hot", "babel-loader?optional[]=es7.comprehensions&optional[]=es7.classProperties&optional[]=es7.objectRestSpread&optional[]=es7.decorators"],
        include: [path.join(__dirname, 'ditto/static')]
      },
      // installing a dev package with npm link breaks hot loader, not sure why. So split it out here to main code above can still be hot loaded
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loaders: ["babel-loader?optional[]=es7.comprehensions&optional[]=es7.classProperties&optional[]=es7.objectRestSpread&optional[]=es7.decorators"],
        include: [path.join(__dirname, '../lib/redux-rest')]
      }
    ]
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new BundleTracker({filename: './webpack-stats.json'}),
  ],
  resolve: {
    extensions: ['', '.js', '.jsx']
  }
};

@@ -130,16 +130,18 @@
 rts = %7B%0A
+  
   contex
@@ -156,17 +156,21 @@
 name,%0A  
-%0A
+  %0A  
   entry:
@@ -168,24 +168,28 @@
    entry: %5B%0A
+    
     'webpack
@@ -263,16 +263,20 @@
 nd port%0A
+    
     'web
@@ -306,16 +306,20 @@
 r',%0A    
+ 
+   
 './ditto
@@ -348,16 +348,22 @@
 s',%0A
+  
   %5D,%0A  
-%0A
+  %0A  
   ou
@@ -366,24 +366,28 @@
   output: %7B%0A
+    
     path: pa
@@ -425,16 +425,20 @@
 les/'),%0A
+    
     file
@@ -463,16 +463,20 @@
 h%5D.js%22,%0A
+    
     publ
@@ -613,16 +613,18 @@
 ame%0A
+  
   %7D,%0A%0A  
 modu
@@ -619,16 +619,18 @@
   %7D,%0A%0A  
+ 
+ 
 module: 
@@ -627,24 +627,28 @@
   module: %7B%0A
+    
     loaders:
@@ -652,26 +652,40 @@
 rs: %5B%0A      
+     
+ 
 %7B%0A
+        
         test
@@ -689,32 +689,40 @@
 est: /%5C.jsx?$/,%0A
+        
         exclude:
@@ -738,32 +738,40 @@
 dules/,%0A        
+  
+      
 loaders: %5B%22react
@@ -764,17 +764,17 @@
 aders: %5B
-%22
+'
 react-ho
@@ -774,17 +774,17 @@
 eact-hot
-%22
+'
 , %22babel
@@ -923,525 +923,52 @@
     
-  include: %5Bpath.join(__dirname, 'ditto/static')%5D%0A
       %7D
-,
 %0A      
-// installing a dev package with npm link breaks hot loader, not sure why. So split it out here to main code above can still be hot loaded%0A      %7B%0A        test: /%5C.jsx?$/,%0A        exclude: /node_modules/,%0A        loaders: %5B%22babel-loader?optional%5B%5D=es7.comprehensions&optional%5B%5D=es7.classProperties&optional%5B%5D=es7.objectRestSpread&optional%5B%5D=es7.decorators%22%5D,%0A        include: %5Bpath.join(__dirname, '../lib/redux-rest')%5D%0A      %7D%0A    %5D%0A  %7D,%0A  plugins: %5B%0A
+  %5D%0A    %7D,%0A    plugins: %5B%0A    
     
@@ -1009,16 +1009,20 @@
 ugin(),%0A
+    
     new 
@@ -1078,63 +1078,11 @@
 ,%0A  
-%5D,%0A  resolve: %7B%0A    extensions: %5B'', '.js', '.jsx'%5D%0A  %7D
+  %5D
 %0A%7D;%0A

Revert "Fix webpack to load jsx files and fix hot loading by separating out redux-rest"