const path = require('path')
const webpack = require('webpack')
const ENV = process.env.NODE_ENV || 'development'
const appendIf = (cond, ...items) => cond ? items : []

const plugins = [
  new webpack.DefinePlugin({
    'process.env': { NODE_ENV: JSON.stringify(ENV) }
  }),
  ...appendIf(ENV === 'production', new webpack.optimize.UglifyJsPlugin()),
  ...appendIf(ENV !== 'production', new webpack.HotModuleReplacementPlugin())
]

module.exports = {
  entry: [
    'react-hot-loader/patch',
    './src/index.js'
  ],
  output: {
    path: path.resolve(__dirname, 'static'),
    filename: 'bundle.js'
  },
  resolve: {
    extensions: ['.js', '.jsx']
  },
  plugins: plugins,
  module: {
    rules: [{
      test: /\.jsx?$/,
      exclude: /node_modules/,
      loaders: ['react-hot-loader/webpack', 'babel-loader'],
    }]
  },
  devServer: {
    hot: true,
    contentBase: path.join(__dirname, 'static'),
    publicPath: '/'
  }
}

@@ -185,172 +185,8 @@
 = %5B%0A
-  new webpack.DefinePlugin(%7B%0A    'process.env': %7B NODE_ENV: JSON.stringify(ENV) %7D%0A  %7D),%0A  ...appendIf(ENV === 'production', new webpack.optimize.UglifyJsPlugin()),%0A
   ..
@@ -602,16 +602,25 @@
 aders: %5B
+%0A        
 'react-h
@@ -638,16 +638,24 @@
 ebpack',
+%0A       
  'babel-
@@ -661,16 +661,23 @@
 -loader'
+%0A      
 %5D,%0A    %7D

Remove manual env injection and uglify plugin. webpacks `-p` argument handles this.