const webpack = require('webpack');
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');

// all dependecies from app/package.json will be included in build/node_modules
const externals = require('./app/package.json').dependencies;

module.exports = {
  module: {
    loaders: [{
      test: /\.jsx?$/,
      loaders: ['babel-loader'],
      exclude: /node_modules/
    }, {
      test: /\.json$/,
      loader: 'json-loader'
    }, {
      test: /\.jpe?g$|\.gif$|\.png$|\.svg$|\.woff$|\.ttf$|\.wav$|\.mp3$/,
      loader: 'url-loader'
    }]
  },
  output: {
    path: path.join(__dirname, 'app'),
    filename: '[name].bundle.js',
    libraryTarget: 'commonjs2'
  },
  resolve: {
    extensions: ['', '.js', '.jsx'],
    root: [
      path.resolve('./app'),
      path.resolve('./node_modules'),
    ]
  },
  postcss: () => [
    require('autoprefixer'),
    require('postcss-nested'),
  ],
  plugins: [
    new LodashModuleReplacementPlugin(),
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
    }),
    new CopyWebpackPlugin([
      { from: 'app/main/css/themes/*', to: './main/css/themes/[name].[ext]' }
    ])
  ],
  externals: Object.keys(externals || {})
};

@@ -288,16 +288,28 @@
 rnals = 
+Object.keys(
 require(
@@ -342,17 +342,107 @@
 ndencies
-;
+ %7C%7C %7B%7D);%0Aif (process.platform !== %22darwin%22) %7B%0A  var index = externals.indexOf(%22nodobjc%22);%0A%7D
 %0A%0Amodule
@@ -1387,28 +1387,16 @@
 ernals: 
-Object.keys(
 external
@@ -1396,19 +1396,12 @@
 xternals
- %7C%7C %7B%7D)
 %0A%7D;%0A

remove nodobjc from windows