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

// Let's gather all the node_modules to add to the "externals"
// This is to avoid the issue with webpack trying to pack express's dynamic require.
// http://jlongster.com/Backend-Apps-with-Webpack--Part-I
const externals = {};
fs.readdirSync('node_modules')
  .filter((x) => ['.bin'].indexOf(x) === -1)
  .forEach((mod) => {
    externals[mod] = `commonjs ${mod}`;
  });

const webpackBase = require('./webpack.base.js');
// noinspection JSUnresolvedFunction
module.exports = Object.assign({}, webpackBase, {
  target: 'node',
  devtool: 'source-map',
  entry: {
    server: [
      './app/server.js',
    ],
  },
  output: {
    path: path.join(webpackBase.context, 'dist'),
    filename: '[name].js',
  },
  plugins: [
    new webpack.DefinePlugin({
      __CLIENT__: false,
      __SERVER__: true,
      __PRODUCTION__: true,
      __DEV__: false,
    }),
    new webpack.DefinePlugin({ 'process.env': { NODE_ENV: '"production"' } }),
    new webpack.NoErrorsPlugin(),
    new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 20 }),
  ],
  externals,
});

@@ -950,87 +950,8 @@
 %7D),%0A
-    new webpack.DefinePlugin(%7B 'process.env': %7B NODE_ENV: '%22production%22' %7D %7D),%0A
     

Remove precess.env override from server.js! -.-