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


const getExternals = () => {
  const nodeModules = fs.readdirSync(path.join(process.cwd(), 'node_modules'))
  return nodeModules.reduce((ext, mod) => {
    ext[mod] = 'commonjs ' + mod
    return ext
  }, {})
}

module.exports = {
  target: 'node',
  entry: './server/index',
  output: {
    path: path.resolve(process.cwd(), 'dist'),
    filename: 'server.js'
  },
  externals: getExternals(),
  module: {
    preLoaders: [
      {
        test: /\.js$/,
        loaders: ['eslint'],
        exclude: /node_modules/
      }
    ],
    loaders: [
      {
        test: /\.json$/,
        loader: 'json-loader'
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        plugins: [
          'transform-react-constant-elements',
          'transform-react-inline-elements'
        ],
        exclude: /(node_modules)/
      }
    ]
  },
  plugins: [
    new webpack.IgnorePlugin(/\.(css|less|scss|svg|png|jpe?g|png)$/),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      }
    })
  ],
  stats: {
    version: false,
    hash: false,
    timings: true,
    colors: true,
    chunk: false,
    chunkModules: false
  }
}

@@ -241,18 +241,44 @@
 %3E %7B%0A    
-ex
+const result = ext%0A    resul
 t%5Bmod%5D =
@@ -278,17 +278,17 @@
 %5Bmod%5D = 
-'
+%60
 commonjs
@@ -292,15 +292,15 @@
 njs 
-' + 
+$%7B
 mod
+%7D%60
 %0A   
@@ -307,18 +307,21 @@
  return 
-ex
+resul
 t%0A  %7D, %7B

update on the rules