'use strict';

const webpack = require('webpack')
const path = require('path')

exports.init = (dirname) => {
  const LANG = process.env.LANG || 'en-US'
  const dist = path.join(dirname, 'client', 'public', 'dist')

  return [
  {
    name: 'JS',
    entry: ['whatwg-fetch', path.join(dirname, 'client', 'src', 'app.js')],
    output: {
      filename: path.join(dist, 'build', 'bundle.js')
    },
    plugins: [
      new webpack.optimize.DedupePlugin(),
      new webpack.ProvidePlugin({
          "react": "React"
      }),
      new webpack.optimize.UglifyJsPlugin({
          compress: true,
          comments: false
      })
    ],

    module: {
      loaders: [{
          test: /\.jsx?$/,
          loader: 'babel-loader',
          exclude: [
            /node_modules\/babel[\s\S]*/
          ],
          query: {
            presets: [
              require.resolve('babel-preset-es2015'),
              require.resolve('babel-preset-react')
            ]
          }
        }
      ]}
    }
  ]
}

@@ -616,16 +616,143 @@
 : false%0A
+      %7D),%0A      new webpack.DefinePlugin(%7B%0A        'process.env': %7B%0A          NODE_ENV: JSON.stringify('production')%0A        %7D%0A
       %7D)

use minified react in production